DEV Community

Discussion on: 30 PyTricks I've Learned By Joining the Real Python Mailing List.

Collapse
 
geraldew profile image
geraldew

Well it simply didn't in the environment that I was using, instead it crashed on the tuple. To be clear, the tuple was being used as a key in the Python dictionary, something that Python allows but I'm guessing has no equivalence in JSON.

Thread Thread
 
tompollard61 profile image
Tom Pollard

Yes, JSON keys need to be strings.

In any case, pprint was introduced to the stdlib specifically to handle pretty-printing of Python values, but I don't run across many people who seem to know about it.

Thread Thread
 
geraldew profile image
geraldew

post script - as it happened I was curious enough about JSON versus data structures to try getting it to handle something more than just text keys. So I wrote an experiment about using enumerations - see: