PyWart: Language missing maximum constant of numeric types!

Wolfgang Meiners WolfgangMeiners01 at web.de
Sat Feb 25 03:18:51 EST 2012


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()

Wolfgang



More information about the Python-list mailing list