I forgot to add the following:

>>> setattr(C, "è", u"The letter è")
>>> getattr(C, "è")
u'The letter \xe8'
>>> print getattr(C, "è")
The letter è

Python identifiers can be generic strings, including Latin-1
characters;
they cannot be unicode strings, however:

>>> setattr(C, u"è", "The letter è")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in
position 0: ordinal not in range(128)

So you are right after all, but I though most people didn't know that
you can have
valid identifiers with accented letters, spaces, and non printable
chars.

> setattr(C, " ", "this works")
> getattr(C, " ")


                Michele Simionato

--
http://mail.python.org/mailman/listinfo/python-list
  • ... michele . simionato
    • ... Kent Johnson
      • ... michele . simionato
        • ... Kent Johnson
    • ... Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
    • ... P
      • ... Scott David Daniels
        • ... Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
          • ... Serge Orlov
            • ... Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
              • ... Serge Orlov

Reply via email to