Message315099
| Author | eryksun |
|---|---|
| Recipients | amaury.forgeotdarc, belopolsky, eryksun, meador.inge, smurfix |
| Date | 2018-04-08.23:15:38 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1523229338.47.0.682650639539.issue33242@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
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 example:
>>> s = bytes(range(256)).decode('latin-1')
>>> T = type('T', (), {s: 0})
>>> t = T()
>>> getattr(t, s)
0 |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2018-04-08 23:15:38 | eryksun | set | recipients: + eryksun, amaury.forgeotdarc, belopolsky, smurfix, meador.inge |
| 2018-04-08 23:15:38 | eryksun | set | messageid: <1523229338.47.0.682650639539.issue33242@psf.upfronthosting.co.za> |
| 2018-04-08 23:15:38 | eryksun | link | issue33242 messages |
| 2018-04-08 23:15:38 | eryksun | create | |