By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,814 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,814 IT Pros & Developers. It's quick & easy.

C api: how to create objects?

P: n/a
I bumbed into a seemingly trivial problem: in my C extension I want to
create some very basic Python objects (no methods or attributes) and then
add all the needed attributes according to given information.

How can I do this!? I have tried to make new instances from PyObject with
PyObject_New() and with some other functions as well, but the only result is
that the application comes crashing down. I guess that I am doing something
very wrong.

This Python-code explains what I am trying to do:

class Generic:
pass

data = getData()
new_generic = Generic()

if "color" in data:
new_generic.color_value = data["color"]
elif "position" in data:
...

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.