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/2007-March/071823.html below:

[Python-Dev] Non implementation dependent access to calling scope

[Python-Dev] Non implementation dependent access to calling scope [Python-Dev] Non implementation dependent access to calling scopeMichael Foord fuzzyman at voidspace.org.uk
Sat Mar 10 13:19:22 CET 2007
Hello all,

I realise that this may be more relevant to Python ideas, in which case 
feel free to ignore this (and my apologies).

I occasionally see code looking (something) like :


calling_scope = sys._getframe(1).f_globals['__name__']

This looks and smells like a hack (not least because of the warning in 
the documentation about _getframe), plus stack frames are an 
implementation detail so this code is broken on IronPython. This makes 
me sad.

It would be great to have a specified way to obtain [a read only view on 
(?)] the locals and globals from the calling scope. Perhaps built in 
functions ? If they were specified then the IronPython guys would have 
to implement it for us. B-)

I realise that this can allow bad some bad programming patterns, but 
there are times when it can be very useful.

All the best,

Michael Foord
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