# didn’t test any of this in IronPython
# this may work and/or help you further
# read on about eval, exec and execfile builtins at
# http://docs.python.org/library/functions.html?highlight=execfile#execfile
class GenericFunction(object):
__slots__ = ('__name',)
def __init__(self, name):
self.__name = name
def __call__(self, *args, **kwargs):
print "called %s(args=%r, kwargs=%r)" % (self.__name, args, kwargs)
class Locals(dict):
def __getitem__(self, key):
if not key in self:
self[key] = GenericFunction(key)
return super(Locals, self).__getitem__(key)
exec("""tt(3, yy=4)""", globals(), Locals())
# python -i test.py
called tt(args=(3,), kwargs={'yy': 4})
_______________________________________________
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users