* Mark Rosenblitt-Janssen <dreamingforward at gmail.com> [2015-05-10 11:34:52 -0500]: > Here's something that might be wrong in Python (tried on v2.7): > > >>> class int(str): pass > > >>> int(3) > '3' What's so odd about this? "class int" is an assignment to "int", i.e. what you're doing here is basically: int = str int(3) # really str(3) * Mark Rosenblitt-Janssen <dreamingforward at gmail.com> [2015-05-10 19:14:18 -0500]: > In case the example given at the start of the thread wasn't > interesting enough, it also works in the other direction: > > >>> class str(int): pass > > >>> str('2') > 2 #<----- an integer!!! Same thing. You're shadowing the builtin. Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc I love long mails! | http://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20150511/04d69d80/attachment-0001.sig>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4