singleton objects with decorators

Steven Bethard steven.bethard at gmail.com
Wed Apr 13 00:28:12 EDT 2005


James Stroud wrote:
> Other than using modules, I thought @classmethod took care of this kind of 
> need:
> 
> class SingleThing:
>   some_values = {"fanciness":0}
>   def __init__(self):
>     raise Exception, "not enough preceding stars to be fancy enough"
>   @classmethod
>   def why_so_fancy(self):
>     print "why make every thing so fancy?"
> 
> I call this pattern:
> 
> "Using a Class to Be Something Single Because It Already Is Single"
> 
> or "uactbssbiais", for short.

+1 VOTW (Vocabulation of the Week)

=)

STeVe



More information about the Python-list mailing list