Set run vars with each call

Ben Finney ben+python at benfinney.id.au
Tue Jul 12 23:36:49 CEST 2011


Gnarlodious <gnarlodious at gmail.com> writes:

> OK, [the ‘__init__’ method] sets a value at init time. But is there a
> similar built-in to run whenever the class instance is called?

You can write a ‘__call__’ method which will be called when the instance
is called.

But I suspect that's still not what you're asking.

Maybe it will be quicker to ask: What is it you want to achieve?

-- 
 \      “Compulsory unification of opinion achieves only the unanimity |
  `\        of the graveyard.” —Justice Roberts in 319 U.S. 624 (1943) |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list