homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nadeem.vawda
Recipients Peter.Wentworth, eric.smith, ezio.melotti, mark.dickinson, nadeem.vawda, petri.lehtinen, rhettinger
Date 2011年05月20日.12:05:46
SpamBayes Score 3.7817527e-12
Marked as misclassified No
Message-id <1305893147.11.0.27970074892.issue12127@psf.upfronthosting.co.za>
In-reply-to
Content
The behaviour of int() can be made consistent with the syntax for Python
integer literals by specifying a base of 0:
 >>> int("0050", 0)
 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 ValueError: invalid literal for int() with base 0: '0050'
 >>> int("0o050", 0)
 40
 >>> int("0x050", 0)
 80
 >>> int("0b010", 0)
 2
As for changing the default behaviour, I think it would be a bad idea.
Having ``0050'' be an invalid token is perhaps jarring to people used to
C/C++/Java/etc., but at least attempts to use it fail loudly and
obviously. Having it be valid and yet mean something different could lead
to nasty surprises for the unsuspecting.
History
Date User Action Args
2011年05月20日 12:05:47nadeem.vawdasetrecipients: + nadeem.vawda, rhettinger, mark.dickinson, eric.smith, ezio.melotti, petri.lehtinen, Peter.Wentworth
2011年05月20日 12:05:47nadeem.vawdasetmessageid: <1305893147.11.0.27970074892.issue12127@psf.upfronthosting.co.za>
2011年05月20日 12:05:46nadeem.vawdalinkissue12127 messages
2011年05月20日 12:05:46nadeem.vawdacreate

AltStyle によって変換されたページ (->オリジナル) /