Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > C api: how to create objects?

Reply
Thread Tools

C api: how to create objects?

 
 
Heikki Salo
Guest
Posts: n/a
 
      04-26-2004
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:
...



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Create Api to create document and add,edit,delete text and t Krithika San Ruby 3 11-14-2009 09:29 PM
How can i create new users without utilizing the create user wizar prady ASP .Net 2 12-29-2007 10:46 PM
Can I create a Create .NET 1.1 project in VS2005? JB ASP .Net 1 12-14-2007 10:53 AM
How to create python script which can create csv we file with relationship Sonu Python 1 08-03-2007 01:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57