-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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? > Do you want to call constructor of super-class to initialize the object? If it is true, you have following options.
In old style class: class MyClass(ParentClass): def __init__(self): ParentClass.__init__(self) In new style class: class MyClass(ParentClass): def __init__(self): super(MyClass).__init__(self) Or class MyClass(ParentClass): def __init__(self): super(MyClass, self).__init__() - -- Thinker Li - [EMAIL PROTECTED] [EMAIL PROTECTED] http://heaven.branda.to/~thinker/GinGin_CGI.py -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF+Dls1LDUVnWfY8gRAvDaAKDVmX8LmuWUdJ4eVil7l//rjCQZLQCg8dO8 Y77CL1ikmtdl6S3HD04GWiA= =mvSe -----END PGP SIGNATURE-----
-- http://mail.python.org/mailman/listinfo/python-list