1

I ran into this interesting little 'gotcha' this evening, consider the following code snippet:

( chr(1) == 1 )

This comparison evaluates to False on Python 2.7.4, is this a feature or a bug?, If a feature, can anyone explain the reasoning behind this design decision?

1 Answer 1

5

There's no "char" type in python, chr returns a string of length one, and with strong typing it doesn't make sense for any string to be equal to any integer.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah, my bad, too much time in C and C++ environments :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.