Cookbook idea - single-shot __init__

Bob Gailer bgailer at
Thu Jul 24 03:15:23 CEST 2003

I have at times had the need to initialize some things once at the class 
level, and have resorted to techniques like:

class foo:
   first = True
   def __init__(self):
     if foo.first:
       foo.first = False
       # initialization code

Then a "better idea" occurred:

class foo:
   def __init__(self):
       del foo.__init__
       # initialization code

Bob Gailer
bgailer at
303 442 2625
-------------- next part --------------

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003

More information about the Python-list mailing list