anomaly

Ian Kelly ian.g.kelly at gmail.com
Sun May 10 12:42:58 EDT 2015


On Sun, May 10, 2015 at 10:34 AM, Mark Rosenblitt-Janssen
<dreamingforward at gmail.com> wrote:
> Here's something that might be wrong in Python (tried on v2.7):
>
>>>> class int(str): pass

This defines a new class named "int" that is a subclass of str. It has
no relation to the builtin class int.

>>>> int(3)
> '3'

This creates an instance of the above "int" class, which is basically
equivalent to calling "str(3)".

Were you expecting a different result?



More information about the Python-list mailing list