Why a class when there will only be one instance?

SeeBelow at SeeBelow.Nut SeeBelow at SeeBelow.Nut
Tue May 25 20:43:49 EDT 2004


I see the value of a class when two or more instances will be created,
but Python programmers regularly use a class when there will only be one
instance.
What is the benefit of this?  It has a disadvantage of a whole lot of
"self."
being required everywhere, making the code less readable.  Also, since a
strength of Python is rapid application development, it slows one down
to have to put in all those self.'s.  The code seems much cleaner to me
without classes that have only one instance.  Oh, also, all the methods
of this class will have to have the instance name prepended to them.

I would appreciate it if someone could explain the advantages of doing
this, or at least the sociological reasons why it occurs.

Mitchell Timin

-- 
"Many are stubborn in pursuit of the path they have chosen, few in
pursuit of the goal." - Friedrich Nietzsche

http://annevolve.sourceforge.net is what I'm into nowadays.
Humans may write to me at this address: zenguy at shaw dot ca



More information about the Python-list mailing list