Skip to main content
added 115 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201

... if you know for sure that Elvis has not yet been created, and that King hashas*.


* some ontological issues here: could one singleton ever be another singleton? Subclassing a singleton class seems fraught with problems. And even then you'd probably be asking isinstance(), not is.


... if you know for sure that Elvis has not yet been created, and that King has.

... if you know for sure that Elvis has not yet been created, and that King has*.


* some ontological issues here: could one singleton ever be another singleton? Subclassing a singleton class seems fraught with problems. And even then you'd probably be asking isinstance(), not is.


added 115 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201

... particularly (though not exclusively) if there is doubt concerning the pre-existence of Elvis and/or of that building.

To make this complete you could also override __delattr__() to raise an Exception if an attempt is made to delete instance, and override __del__() so that it raises an Exception (unless we know the program is ending...)

To make this complete you could also override __delattr__() to raise an Exception if an attempt is made to delete instance, and override __del__() so that it raises an Exception (unless we know the program is ending...)

... particularly (though not exclusively) if there is doubt concerning the pre-existence of Elvis and/or of that building.

To make this complete you could also override __delattr__() to raise an Exception if an attempt is made to delete instance, and override __del__() so that it raises an Exception (unless we know the program is ending...)

added 68 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201

The singleton contractsingleton pattern does not require that we be able to call the constructor multiple times. As a singleton should be created once and once only, shouldn't it be seen to be created just once? "Spoofing" the constructor arguably impairs legibility.

The singleton contract does not require that we be able to call the constructor multiple times. As a singleton should be created once and once only, shouldn't it be seen to be created just once? "Spoofing" the constructor arguably impairs legibility.

The singleton pattern does not require that we be able to call the constructor multiple times. As a singleton should be created once and once only, shouldn't it be seen to be created just once? "Spoofing" the constructor arguably impairs legibility.

added 17 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
edited body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
added 57 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
Reword, reformat, and make the later example work in CPython
Source Link
theheadofabroom
  • 22.4k
  • 5
  • 35
  • 65
Loading
deleted 28 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
added 40 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
added 40 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
added 15 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
deleted 277 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
improved/alternative version
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
added 18 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
added 104 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
added 104 characters in body
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading
Source Link
mike rodent
  • 16.1k
  • 14
  • 120
  • 201
Loading