how do you get the name of a dictionary?

Andy Terrel andy.terrel at gmail.com
Fri Aug 18 14:45:05 EDT 2006


jojoba wrote:
> Hello!
>
> Does anyone know how to find the name of a python data type.
>
> Conside a dictionary:
>
> Banana = {}
>
> Then, how do i ask python for a string representing the name of the
> above dictionary (i.e. 'Banana')?
>
> thanks to anyone who has time to answer this nube question!
> jojoba

here is an easy hack,  I don't know if there is an explicit function.


for i in dir():
     if eval(i) == Banana:
             print i




More information about the Python-list mailing list