[Python-Dev] Python3 "complexity"

Chris Angelico rosuav at gmail.com
Thu Jan 9 02:36:01 CET 2014


On Thu, Jan 9, 2014 at 11:21 AM, MRAB <python at mrabarnett.plus.com> wrote:
> On the other hand:
>
>     "I need a new battery."
>
>     "What kind of battery?"
>
>     "I don't care!"

Or, bringing it back to Python: How do you write a set out to a file?

foo = {1, 2, 4, 8, 16, 32}
open("foo.txt","w").write(foo)  # Uh... nope!

I don't want to have to worry about how it's formatted! I just want to
write that set out and have someone read it in later!

A text string is just as abstract as any other complex type. For some
reason, we've grown up thinking that "ABCD" == \x61\x62\x63\x64 ==
"ABCD", even though it's just as logical for those bytes to represent
12.1414 or 1094861636 or 1145258561. There's no difference between
encoding one thing to bytes and encoding another thing to bytes, and
it's critical to get those encodes/decodes right.

ChrisA


More information about the Python-Dev mailing list