Python Gotcha's?

Chris Angelico rosuav at gmail.com
Thu Apr 5 12:47:14 EDT 2012


On Fri, Apr 6, 2012 at 2:25 AM, Grzegorz Staniak <gstaniak at gmail.com> wrote:
> On 05.04.2012, Roy Smith <roy at panix.com> wroted:
>
>> There's absolutely no reason why JSON should follow Python syntax
>> rules. Making it support either kind of quotes would have
>> complicated every JSON library in the world, for no added value.
>
> I think these days it's not just "Python syntax", it's kinda something
> that you can get accustommed to take for granted. Realistically, how
> much more complication could the support for either quote marks
> introduce? I doubt anyone would even notice. And you don't have to
> write JSON by hand for this gotcha to bite you, all it takes is to
> start playing with generating JSON without the use of specialized
> JSON libraries/functions. For testing, for fun, out of curiosity...

It all depends on the language. C and several C-derived languages
distinguish between "string constants" and 'integer constants', where
the latter are defined by character codepoint; PHP and bash have
"interpolated strings" and 'non-interpolated strings'; Python and REXX
have no difference between the two. All are legitimate design choices.

Assuming that multiple languages/protocols have the same flexibility
is dangerous, and I'm not surprised that JSON's strictness is biting
people. Maybe the weird error message should be addressed as a bug,
and then there won't be a problem :)

ChrisA



More information about the Python-list mailing list