Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7793511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:30:42+00:00 2026-06-01T22:30:42+00:00

I was wondering whether (and how) one can create empty c type arrays in

  • 0

I was wondering whether (and how) one can create empty c type arrays in python. The following code works fine if I want to initialize an array with zeros:

from ctypes import *
data = [0 for i in xrange(10)]
a = ((c_float *10))(*data)

If data is a list of None values however, I get an error message:

data = [None for i in xrange(10)]
a = ((c_float *10))(*data)

TypeError:  float expected instead of NoneType instance

is there a way to initialize and array with NONEs or NULLs?

EDIT 1:
the reason why I want an array with None / Null is that I want to upload this array to the GPU. If I initialize my array with Zeros, then zeros will be rendered. However if I initialize it will NULL (as defined in c), nothing is rendered.

EDIT 2:
the reason for using c_float is that I need to cast my data to c_float in order for it to be compatible with opengl.

EDIT 3:
if data is made of zeros, then the following code will render me a bunch of points @ location 0 / 0. I was hoping that sending NULL values to the GPU will not result in any points being rendered.

glBindBuffer(GL_ARRAY_BUFFER, vbo)    
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(data), data)
glVertexPointer(n_COORDINATES_PER_VERTEX, GL_FLOAT, 0, 0)
glDrawArrays(GL_LINE_STRIP, 0, len(data))

EDIT 4:
Another use-case when you might want to use NULL in python: according to the opengl website, the following is how to allocate memory on the GPU:

glBufferData(GL_ARRAY_BUFFER, SizeInBytes, NULL, GL_STATIC_DRAW)

If I do this in my python code, I get the following error: NameError: global name 'NULL' is not defined

but there must be a way to do this in python, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:30:43+00:00Added an answer on June 1, 2026 at 10:30 pm

    A c_float has no equivalent value for ‘None’, so you can’t store None in a c_float.

    See the table in the python ctypes docs – there are some types that support None – but none that support both floats and None.

    You will have to use an alternate data type, record None values separately somehow, or find a way of representing None as a float that works for your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering whether we can declare session.gc_maxlifetime setting in .htaccess for the one
I was wondering whether someone can shed some light on the following issue: We've
I was wondering whether there is a tool available that one can use to
I wondering whether use a webView to create a complex text area done with
I was wondering whether there is a way to make html5 code visible in
I am wondering whether I can upgrade a basic IoC container I am using
I'm wondering about some details of how for ... in works in Python. My
I was wondering whether RSA can be cracked given: The public key A plaintext
I'm wondering whether I can use the same runtime folder by placing it in
I am wondering if the following is a known issue and whether there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.