True, False, None

Michele Simionato mis6 at pitt.edu
Wed Nov 12 09:06:00 EST 2003


"Andrew Dalke" <adalke at mindspring.com> wrote in message news:<Eemsb.8193$nz.6586 at newsread2.news.pas.earthlink.net>...
> Michele Simionato
> > Better to say: singletons are classes. But True and False are not
> > classes (no '__base__' attribute, for instance) so they are not
> > singletons.
> 
> I don't follow your statement.
> 
> Not all singletons are classes.  Imported modules are
> singletons, yes?  And as an implementation choice the
> numbers -1 to 100 are singletons as are the single character
> byte strings.  (Implementation choice since the spec requires
> that None references a singleton but not that 1 and 3-2
> always reference the same object.)

It is solely a matter of conventions. I am used to the definition
"a singleton is a class with only one instance". According to this
definition a singleton is a class. But it is true that a lot of
people extend the meaning to modules or numbers, so you are also
right. It is unfortunate that many concept in CS are not very well
defined (or, even if well defined, the right definition is not
universally known).

                              Michele




More information about the Python-list mailing list