Python Gotcha's?

Chris Angelico rosuav at gmail.com
Thu Apr 5 14:24:00 EDT 2012


On Fri, Apr 6, 2012 at 4:08 AM, Roy Smith <roy at panix.com> wrote:
>> If you are working with data that is representable as either an integer
>> or a string, choose one and stick to it.  Treating it as both/either will
>> eventually lead to grief.
>>
>> Or, in other words: 1 != '1'
>
> Tell that to the PHP crowd :-)

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.

ChrisA



More information about the Python-list mailing list