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