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/2000-January/001852.html below:

[Python-Dev] Changing existing class instances

[Python-Dev] Changing existing class instancesGreg Stein gstein@lyra.org
Fri, 21 Jan 2000 03:12:57 -0800 (PST)
On Thu, 20 Jan 2000, Guido van Rossum wrote:
> Tim Peters:
>...
> > At the time my.py defines Misc, does Misc count as a class we're "about to
> > stomp on"?  If so-- & I've assumed so --it would wreak havoc.
> > 
> > But if not, I don't see how this case can be reliably distinguished "by
> > magic" from the cases where update is desired (if people are doing dynamic
> > updates to a long-running program, a new version of a class can come from
> > anywhere, so nothing like original file name or line number can distinguish
> > correctly either).
> 
> Fortunately, there's magic available: recently, all classes have a
> __module__ attribute that is set to the full name of the module that
> defined it (its key in __sys__.modules).
> 
> For functions, we would have to invent something similar.

func.func_globals


__module__ and func_globals can prevent *other* modules from redefining
something accidentally, but it doesn't prevent Badness from within the
module.
[ Tim just posted an example of this: his "def adder()" example... ]

Cheers,
-g

-- 
Greg Stein, http://www.lyra.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