Finding name of variable?

Gonzalo HIGUERA DÍAZ gonhidi at gmail.com
Tue Sep 5 10:02:19 EDT 2006


2006-09-05 15:49 +0200, Gardner Pomper <gardner at networknow.org>:
> Hi,
>
> I am writing a specialized xml serialization function, and I would like to
> be able to serialize the value of a simple object with the object name as
> the tag. For example:
>
>    first_name = 'Fred'
>
>   sXML = my_xml_serializer(first_name)
>
> should result in sXML = '<first_name>Fred</first_name>'
>
> I can get class and field names, but how do I find the name of a simple
> variable?

A recent thread[1] might be a useful starting point.


[1] "how do you get the name of a dictionary?" URL:
<http://mail.python.org/pipermail/python-list/2006-August/357006.html>

-- 
Gonzalo HIGUERA DÍAZ <gonhidi at gmail.com>



More information about the Python-list mailing list