Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #90300 > unrolled thread

Re: anomaly

Started byTerry Reedy <tjreedy@udel.edu>
First post2015-05-10 13:09 -0400
Last post2015-05-10 13:09 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: anomaly Terry Reedy <tjreedy@udel.edu> - 2015-05-10 13:09 -0400

#90300 — Re: anomaly

FromTerry Reedy <tjreedy@udel.edu>
Date2015-05-10 13:09 -0400
SubjectRe: anomaly
Message-ID<mailman.320.1431277765.12865.python-list@python.org>
On 5/10/2015 12:34 PM, Mark Rosenblitt-Janssen wrote:
> Here's something that might be wrong in Python (tried on v2.7):

You are being hypnotized by the fact the 'int' is a builtin name. 
Builtin names are not keywords and can intentionally be rebound.  If you 
rebind randomly, the result may seem strange, but is predictable.  This 
is why be recommend not randomly reusing names of builtins.

>>>> class int(str): pass

This in effect rebinds 'int' to the str class.  The work 'int' no longer 
has any connect to the builtin integer class.

>>>> int(3)

Equivalent to str(3)

> '3'

No surprise that str(3) == '3'.

Replace 'int' with anything else, such as 'zyz' or 'Mark' in both 
statements and the result is the same.

-- 
Terry Jan Reedy

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web