[Python-Dev] AC Derby and accepting None for optional positional arguments

Serhiy Storchaka storchaka at gmail.com
Thu Jan 16 09:31:17 CET 2014


16.01.14 08:05, Guido van Rossum написав(ла):
> In this specific case it's clear to me that the special-casing of
> negative count is intentional -- presumably it emulates sequence
> repetition, where e.g. 'a'*-1 == ''.

In this specific case it's contrary to sequence repetition. Because 
repeat('a', -1) repeats 'a' forever. This is a point of Vajrasky's issue 
[1].

> But not accepting None is laziness -- accepting either a number or
> None requires much more effort, if you need to have the number as a C
> integer. I'm not sure how AC could make this any easier, unless you
> want to special-case maxint or -maxint-1.

getattr(foo, 'bar', None) is not the same as getattr(foo, 'bar'). So 
None can't be used as universal default value.


[1] http://bugs.python.org/issue19145




More information about the Python-Dev mailing list