[Python-Dev] anomaly
Paul Moore
p.f.moore at gmail.com
Mon May 11 10:12:24 CEST 2015
More information about the Python-Dev mailing list
Mon May 11 10:12:24 CEST 2015
- Previous message (by thread): [Python-Dev] anomaly
- Next message (by thread): [Python-Dev] Is it kosher to use a buffer after release?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10 May 2015 at 17:34, 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 > >>>> int(3) > '3' It's not wrong as such. It is allowed to define your own class that subclasses a builtin class, and it's allowed to shadow builtin names. So while this is (obviously) bad practice, it's not wrong. For a simpler example: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> str <class 'str'> >>> str = "Hello" >>> str 'Hello' Paul
- Previous message (by thread): [Python-Dev] anomaly
- Next message (by thread): [Python-Dev] Is it kosher to use a buffer after release?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list