Nick Coghlan wrote: > [ much good, including the @instance decorator ] > P.S. If all you want is somewhere to store mutable > state between invocations, you can always use the > function's own attribute space >>> def f(): print "Hi world from %s!" % f >>> f() Hi world from <function f at 0x00AE90B0>! Not really. That assumes the expected name is (permanently) bound to *this* function in this function's globals. That's normally true, but not always, so relying on it seems wrong. >>> f="a string" >>> g() Hi world from a string! And of course, sometimes I really do want shared state, or helpers (like other methods on a class), or one-time ininitialization plus per-call parameters (like the send method on 2.5 generators), or ... -jJ
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