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

Thanks!

- Gardner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-list/attachments/20060905/2ca941b0/attachment.html

Search Discussions

  • Gonzalo HIGUERA DÍAZ at Sep 5, 2006 at 2:02 pm

    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>
  • Gabriel Genellina at Sep 12, 2006 at 5:00 am

    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedSep 5, '06 at 1:49p
activeSep 12, '06 at 5:00a
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase