Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34478 > unrolled thread

empty object from C

Started byEric Frederich <eric.frederich@gmail.com>
First post2012-12-07 10:42 -0500
Last post2012-12-07 10:42 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  empty object from C Eric Frederich <eric.frederich@gmail.com> - 2012-12-07 10:42 -0500

#34478 — empty object from C

FromEric Frederich <eric.frederich@gmail.com>
Date2012-12-07 10:42 -0500
Subjectempty object from C
Message-ID<mailman.612.1354898619.29569.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Hello,

>From C, I'd like to call a Python function that takes an object and sets
some attributes on it.
Lets say this is the function...

def foo(msg):
    msg.bar = 123
    msg.spam = 'eggs'

How do I create an empty object in C?
In Python I would do something like this...

class Msg(object):
    pass

... and then instantiate an instance, and call the function.

msg = Msg()
foo(msg)



I know how to create an empty dictionary and I get get by with that, but
I'd like to create an object.

Thanks,
~Eric

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web