singleton ... again

Ben Finney ben+python at benfinney.id.au
Wed Feb 12 22:07:55 EST 2014


Steven D'Aprano <steve at pearwood.info> writes:

> On Wed, 12 Feb 2014 23:04:32 +1300, Gregory Ewing wrote:
> > If you really want to make sure nobody creates another instance by
> > accident, delete the class out of the namespace after instantiating
> > it.
>
> That does not work. It is trivial to get the type from an instance [by
> calling ‘type(foo)’].

Right, but surely you don't think people would do that “by accident”,
which is what Gregory was addressing.

-- 
 \            Hercules Grytpype-Thynne: “Well, Neddie, I'm going to be |
  `\      frank.”  Ned Seagoon: “Right, I'll be Tom.”  Count Moriarty: |
_o__)           “I'll be Gladys.” *slap* —The Goon Show, _World War I_ |
Ben Finney




More information about the Python-list mailing list