On 3/14/07, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
>
> - In 3.0, we don't want an exception.  With floats and decimals, leading 
> zeroes are allowed (i.e.  0.123).  In 3.0, I would like the leading zero 
> distinction to disappear from our collective memory.  Somelike like 
> eval('00987') should give 987, not an exception.  The use cases for zfill() 
> correspond to the cases where leading zeros are meaningfully interpreted as 
> decimals (this includes phone and social security numbers, account numbers, 
> and whatnot).

This is the only part I'm not sure I agree with. I agree it would be
nice if there were no collective memory, but it is etched into the
collective memory, and anybody who uses C or some other language as
well as Python is living that collective memory on a daily basis and
could easily do the wrong thing (either in Python or in the other
language).  We are removing the ability to specify an octal number via
a leading 0, because it caused confusion.  I think adding the ability
to specify a decimal number with a leading 0 has the potential to
cause confusion in a completely different group of users.  And it
doesn't seem to be something people are clamoring for in a major way.

In fact, I would go so far as to argue that the behavior of int()
should be changed as well:

    int('012')       -> exception (used to return 12)
    int('012', 0)   -> exception (used to return 10)
    int('012', 10) -> should return 12, like always

So for your use-cases:  1) you shouldn't hard code an SSN into the
program; 2) you shouldn't use eval() on user data; and 3) you should
call int() with a second parameter of 10 to get what you want.

Regards,
Pat
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to