A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-March/043542.html below:

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

[Python-Dev] decorators (not transformations) on functions vsclasses [Python-Dev] decorators (not transformations) on functions vsclassesRobert 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

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