3 ms·
You're right that __repr__ was not mentioned, my bad. I think `.encode(locale.getpreferredencoding())` is awful because this changes string encoding from run t
by kmike84 13y ago
You're right that __repr__ was not mentioned, my bad.
I think `.encode(locale.getpreferredencoding())` is awful because this changes string encoding from run to run, and because locale.getpreferredencoding() could be different (and is different by default e.g. in Cyrillic Windows XP) from both `sys.stdout.encoding` (used for printing) and `sys.getdefaultencoding()` (used for implicit type conversions).
- JulianWasTaken 13y agoGood point. Honestly I'm careful about calling str on random objects which I know are doing this. But yeah, I guess that's probably a good enough reason to pick an encoding and go with it, which `utf-8` is a good of a choice as any.