'Once' properties.

Chris Rebert clp2 at rebertia.com
Mon Oct 5 23:04:21 EDT 2009


On Mon, Oct 5, 2009 at 7:56 PM, menomnon <patf at well.com> wrote:
> Does python have a ‘once’ (per class) feature?

In Python, `class` is an executable statement, so you can put whatever
code you want in the class body (along with your method definitions)
and it will be run exactly once, at the time the class is defined
(that is, when the `class` statement is encountered by the
interpreter). In this way, you could create class variables containing
such static information.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list