Eryk Sun <> added the comment:

If you're automatically wrapping a C source file and don't know the source 
encoding, you could naively decode it as Latin-1. You're still faced with the 
problem of characters that Python doesn't allow in identifiers. For example, 
gcc allows "$" in C identifiers (e.g. a field named "egg$"), but Python doesn't 
allow this character. At least you can use getattr() to access such names. For 

    >>> s = bytes(range(256)).decode('latin-1')
    >>> T = type('T', (), {s: 0})
    >>> t = T()
    >>> getattr(t, s)


Python tracker <>
Python-bugs-list mailing list

Reply via email to