anomaly

Gary Herron gherron at digipen.edu
Sun May 10 21:07:36 EDT 2015


On 05/10/2015 05:48 PM, zipher wrote:
> On Sunday, May 10, 2015 at 11:44:36 AM UTC-5, Ian wrote:
>> 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?
> Sorry, yes.  If you're going to define a concept called "keywords", I don't think you should allow them to be shadowed by a class definition.
>
> Mark

Huh?   Python has plenty of keywords, and indeed, none of them can be 
redefined or shadowed.    But you would gain nothing (and lose a bit or 
dynamic-language freedom) by making int a keyword.

-- 
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418




More information about the Python-list mailing list