On 4/5/2012 13:24, Chris Angelico wrote:
> I think this example highlights a major point about gotchas: the
> difference between an obvious language feature and a gotcha depends on
> where you come from. To a PHP programmer, 1 and "1" are in many ways
> indistinguishable. To a C programmer, they're utterly incompatible.

I think I agree with this. For instance, I'd consider the fact that this
works in Python to be a gotcha:

  >>> 1 < "abc"
  True

But that's because I like more strongly-typed systems. [I'm most
decidedly not trying to start up that discussion again...]


This is changed in Python 3:

  >>> 1 < "abc"
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  TypeError: unorderable types: int() < str()

though you can still compare *some* types I consider logically unorderable:

  >>> 0 < True
  True


I think it also has bearing on the ' vs " issue. For instance, I totally
think it's not at all surprising that one can be accepted and the other
not, or that they behave differently. (Though I *do* find it surprising
in the context of JSON given that JS apparently allows either.)

Evan

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to