Jewett, Jim J wrote: > def bar(): > pass > bar.x = 27 > > is not so useful. > > There is no intermediate "self" scope between function locals > and global, so bar itself can't see x. Functions do not inherit, > so there won't be any instances or subfunctions that could be > affected. Using a function's attributes to control another > function's execution path is surprising. True, but you can also write: >>> def bar(): ... bar.x = 4 ... >>> bar() >>> bar.x 4 ...so bar itself can "see x", just not until the function is evaluated, in this example. Classes, in this sense, simply differ by being evaluated when they are declared. Robert Brewer MIS Amor Ministries fumanchu at amor.org
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