Re: extension type attributes
Greg Ewing <[email protected]> Sun, 31 May 2009 13:26:03 +1200
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[email protected]> |
horace wrote:
> do all attributes have to be cdef? if i want to have a python object as
> an attribute i have to use
>
> cdef object mypythonobject
Effectively, yes, because extension types don't have
a __dict__ and therefore can't have ordinary Python
attributes. (They're like built-in types in that
regard.)
Note that you can use 'public' or 'readonly' to
make these attributes accessible from Python, e.g.
cdef public object mypythonobject
> and then initialize it in __init__()?
That's optional -- if you don't initialise it, the
initial value will be None.
--
Greg