[Python-ideas] Disallow "00000" as a synonym for "0"
rosuav at gmail.com
Mon Jul 20 04:46:31 CEST 2015
On Mon, Jul 20, 2015 at 12:14 PM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
> On Sun, Jul 19, 2015 at 10:01 PM, Steven D'Aprano <steve at pearwood.info>
>> Allowing 00 when 01, 02, 03, ... are (rightly!) forbidden feels ugly and
>> a wart.
> I agree in general, but there is one case where I am on the fence:
> dates = [ date(2005, 07, 01),
> date(2005, 11, 15),
> looks marginally better than the valid alternative. I often see this form
> written by 2.7 users,
> and it requires a medium size lecture to explain why they should not write
> code like this even
> if it seemingly works.
The lecture should be fairly simple. Just put 08 in there and you'll
see why you shouldn't do it. :)
If they then ask "Why is 07 allowed but 08 not?", then you can go into
detail about octal, why C uses 0755 to mean 493 (and why it makes a
LOT more sense to key some things in using octal - nobody would
understand what permissions 493 would mean), and then it becomes
pretty clear that there are two viable interpretations for "0755".
More information about the Python-ideas