I would like to adapt the following code to IronPython, but there appears to
be no inspect module available.
Any clues on how I might proceed?
many tias,
gary
# code begins
# a hack to support something like dynamically scoped variables
import inspect
class _gsDynamicVars( object ):
def __init__( self ):
self._publics = {}
def setPublic( self, nm, x = None ):
self._publics[nm] = x
def __getattribute__( self, nm ):
for f in inspect.stack():
if f[0].f_locals.has_key( '_privates' ):
if f[0].f_locals[ '_privates' ].has_key( nm ):
return f[0].f_locals['_privates'][nm]
return self._publics.get(nm)
def __setattr__( self, nm, x = None ):
for f in inspect.stack():
if f[0].f_locals.has_key( '_privates' ) :
if f[0].f_locals[ '_privates' ].has_key( nm ) :
f[0].f_locals['_privates'][nm] = x
return x
if self._publics.has_key( nm ) :
self._publics[nm] = x
raise NameError
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com