PyWart: Language missing maximum constant of numeric types!
MRAB
python at mrabarnett.plus.com
Sat Feb 25 12:54:56 EST 2012
On 25/02/2012 08:18, Wolfgang Meiners wrote:
> Am 24.02.12 14:37, schrieb Rick Johnson:
>> I get sick and tired of doing this!!!
>>
>> if maxlength == UNLIMITED:
>> allow_passage()
>> elif len(string)> maxlength:
>> deny_passage()
>>
>> What Python needs is some constant that can be compared to ANY numeric
>> type and that constant will ALWAYS be larger!
>>
>>
>>
> If there is no limit for len(string), why not simply use
>
> # get_limit() returns None if there is no limit
> maxlength = get_limit()
> if maxlength and (len(string)<= maxlength):
> allow_passage()
> else:
> deny_passage()
>
That should be:
if maxlength is not None and len(string) <= maxlength:
More information about the Python-list
mailing list