factory functions & methods

Aaron Brady castironpi at gmail.com
Sun Mar 8 18:08:32 EDT 2009


Hello,

I am creating a container.  I have some types which are built to be
members of the container.  The members need to know which container
they are in, as they call methods on it, such as finding other
members.  I want help with the syntax to create the members.
Currently, the container has to be a parameter to the instantiation
methods.  I want the option to create members with attribute syntax
instead.

Currently, I have:

cA= Container( )
obA= SomeType( cA )
obB= OtherType( cA, otherarg )

I want:

cA= Container( )
obA= cA.SomeType( )
obB= cA.OtherType( otherarg )

What are my options?

P.S.  The container and members are C extension types, not pure Python.



More information about the Python-list mailing list