[Python-Dev] decorators (not transformations) on functions vsclasses (original) (raw)

Robert Brewer fumanchu at amor.org
Fri Mar 26 13:23:25 EST 2004


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



More information about the Python-Dev mailing list