Cookbook idea - single-shot __init__

Bob Gailer bgailer at alum.rpi.edu
Wed Jul 23 21:15:23 EDT 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 alum.rpi.edu
303 442 2625
-------------- next part --------------

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


More information about the Python-list mailing list