Here's a **very** hackish code I threw up together. It requires a lot of manual checking and, I don't think it's practical at all.
###input: default = set(locals()) class test(): def __init__(self): self.name = str(self) self.val = 'Mrra' a = test() user = set(locals()) - default loc = dict(locals()) for item in loc.items(): if item[0] in user: print(item) ###output: ('a', <__main__.test object at 0x0000000002D6A240>) ('default', {'__builtins__', '__name__', '__file__', '__doc__', '__package__'}) ('test', <class '__main__.test'>) Cheers, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ On Thu, Sep 24, 2009 at 10:49 AM, Rhodri James <rho...@wildebst.demon.co.uk>wrote: > On Thu, 24 Sep 2009 01:34:35 +0100, andrew cooke <and...@acooke.org> > wrote: > > >> For example, I assume it's possible to somehow access the dictionary >> for the current block, but I can't see how to do this after >> assignment. If I do it in the Foo constructor, for example, "a" will >> not yet be bound. >> > > I apologise for failing to notice earlier that you know what you're > talking about. I blame the hour :-) > > I'm not sure you can access the namespace dictionary of the "current > block" (module?), that's the problem. Oh, except via locals(), which > might do exactly what you're after depending. Excuse me, I'm being > very dim tonight. > > -- > Rhodri James *-* Wildebeest Herder to the Masses > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list