On Sep 18, 3:08 pm, rantingrick <rantingr...@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.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to