how do you get the name of a dictionary?
Georg Brandl
g.brandl-nospam at gmx.net
Fri Aug 18 17:36:56 EDT 2006
Andy Terrel wrote:
> Why bang your head?
Because there's no chance that the original request is sane.
If you want your objects to know their name, give them a name as an attribute.
> It was a stupid hack that has lots of problems,
> but done in a way that is readable. Sure I could do something more
> functional or one lined like:
>
> Banana={}
> names = filter(lambda x:id(eval(x))==id(Banana),dir())
>
> but I am guessing that it is harder to read by many. Anywho I can
> think of plenty of reasons it would fail, but it really depends on the
> app.
Georg
More information about the Python-list
mailing list