Understanding Python Numerology -
Understanding Python Numerology -
we can not declare integer start 0.
>>> n = 08 syntaxerror: invalid token
but declare variable contains zeros.
>>> n = 00000 >>> print n >>> 0
so question in first case why python not consider value of variable n = 8
ignoring 0 on left side instead of raising exception. in sec case still considering zeros valid value.
consider case.
>>> n = '0008' >>> print int(n) >>> 8
now in 3rd case still considering valid numeric value, why exception not raised here??
numbers origin 0 , containing no decimal point interpreted octal (using digits 0-7). 08 not valid octal number. according pep index, "the ability specify octal number using leading 0 removed language in python 3.0 (and python 3.0 preview mode of 2.6), , syntaxerror raised whenever leading "0" followed digit" can found here http://www.python.org/dev/peps/pep-3127/
python
Comments
Post a Comment