Calling a class instance like a function
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Thu Feb 19 03:33:56 EST 2009
Uberman a écrit :
> I'm wondering if there's a way to invoke a "function" operator on a Python
> class instance. For example, given a class instance:
>
> myClass = MyClass()
>
> I want to call that instance like a function, with an argument value:
>
> myClass(5.0)
>
> I can override the "()" operator in C++, so I'm wondering if there's a way to
> do it in Python as well.
Filip already answered, but you may want to read this anyway:
http://docs.python.org/reference/datamodel.html#special-method-names
HTH
More information about the Python-list
mailing list