A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-April/063253.html below:

[Python-Dev] Class decorators

[Python-Dev] Class decoratorsJim Jewett jimjjewett at gmail.com
Sat Apr 1 00:01:54 CEST 2006
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
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