Could anyone explain __class__?
mkent at atlantic.net
Sat May 19 17:15:10 CEST 2001
I'm having trouble understanding the function of the built-in class method
__class__. The documentation is terse, to say the least.
>From code examples (UserList.py, forex.), it appears that self.__class__()
returns a new instance of the class of the instance in which it is called.
This would imply that the new instances' __init__ method would be called,
which would mean that you must make sure that you give __class__() the
correct arguments, just like you would if you instantiated the class in
the normal method (e.g. myInstance = UserList(<args>)).
Am I right, wrong, close, or what?
More information about the Python-list