When ‘super’ is not a good idea (was: 'Once' properties.)

2009-10-07 Thread Ben Finney
Scott David Daniels writes: > Scott David Daniels wrote: > > class Initialized(ClassBase): > > @classmethod > > def _init_class(class_): > > class_.a, class_.b = 1, 2 > > super(Initialized, class_)._init_class() > > Mea culpa: Here super is _not_ a goo

Re: 'Once' properties.

2009-10-06 Thread Scott David Daniels
Scott David Daniels wrote: ... Look into metaclasses: ... class Initialized(ClassBase): @classmethod def _init_class(class_): class_.a, class_.b = 1, 2 super(Initialized, class_)._init_class() Mea culpa: Here super is _not_ a good idea, and I had t

Re: 'Once' properties.

2009-10-05 Thread Scott David Daniels
menomnon wrote: Does python have a ‘once’ (per class) feature? ‘Once’, as I’ve know it is in Eiffel. May be in Java don’t. The first time you instantiate a given class into an object it constructs, say, a dictionary containing static information. In my case static is information that may chan

Re: 'Once' properties.

2009-10-05 Thread Carl Banks
On Oct 5, 11:07 pm, Carl Banks wrote: > On Oct 5, 7:56 pm, menomnon wrote: > > Does python have a ‘once’ (per class) feature? > > > ‘Once’, as I’ve know it is in Eiffel.  May be in Java don’t. > > > The first time you instantiate a given class into an object it > > constructs, say, a dictionary c

Re: 'Once' properties.

2009-10-05 Thread Carl Banks
On Oct 5, 7:56 pm, menomnon wrote: > Does python have a ‘once’ (per class) feature? > > ‘Once’, as I’ve know it is in Eiffel.  May be in Java don’t. > > The first time you instantiate a given class into an object it > constructs, say, a dictionary containing static information.  In my > case stati

Re: 'Once' properties.

2009-10-05 Thread Chris Rebert
On Mon, Oct 5, 2009 at 7:56 PM, menomnon 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 de

'Once' properties.

2009-10-05 Thread menomnon
Does python have a ‘once’ (per class) feature? ‘Once’, as I’ve know it is in Eiffel. May be in Java don’t. The first time you instantiate a given class into an object it constructs, say, a dictionary containing static information. In my case static is information that may change once a week at