Edward Loper <edloper at gradient.cis.upenn.edu>: > On a related note, now that Python has class methods, is there much > point in a "singleton" pattern? In particular, why not just make a > class that only defines class methods, and uses the class namespace to > store variables (instead of an instance namespace)? Classes do various magic things on attribute lookups that you might not want for an object that isn't meant to be used as a class. For a while I've been wondering whether Python should have an "instance" statement that's analogous to "class" but creates an instance instead, e.g. instance fred(Foo): blarg = 42 def f(): do_something() would be equivalent to something like class _fred(Foo): def f(): do_something() fred = _fred() fred.blarg = 42 People working on interactive fiction would love something like this, I expect. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4