Constructor of object

Sylvain Defresne sylvain at eugensystems.com
Wed Mar 14 13:57:57 EDT 2007


inline wrote:
> Hello!
> I want to assign self to object of parent class in constructor, like
> 
> def my_func():
>     ...
>     return ParentClass()
> 
> class MyClass (ParentClass):
>     def __init__(self):
>         self = my_func()
> 
> but it not work, because "object not initialized". What i can do?
> 

You want to override the __new__ function.



More information about the Python-list mailing list