Finding name of variable?

Gabriel Genellina gagsl-py at yahoo.com.ar
Tue Sep 12 07:00:41 CEST 2006


At Tuesday 5/9/2006 10:49, Gardner Pomper wrote:

>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?

There was a thread a few days ago about this - there are esoteric 
ways to obtain the object name(s), but I would use:
         sXML = my_xml_serializer('first_name',first_name)
because it's rather clear, and I think you would not use such things a lot.

Remember that a single object may be known as many names, or even 
anonymous - they are not unique.



Gabriel Genellina
Softlab SRL 


	
	
		
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas




More information about the Python-list mailing list