class initialization problem
wuwei23 at gmail.com
Fri Sep 18 07:16:32 CEST 2009
On Sep 18, 3:08 pm, rantingrick <rantingr... at gmail.com> wrote:
> ok here is some code. this will cause an infinite recursion.
> class A():
> def __init__(self, *args):
> self.nestedA = A(*args) #NO GOOD!
> there must be a way to create an instance of an object within the same
> objects constructor?
But if _every_ instance of A has a 'nested' instance of A, won't it
_always_ end up smacking up against the recursive depth limit?
It's beginning to sound like you need to separate the creation out to
a factory function. And to rethink your design, maybe.
More information about the Python-list