PyWart: Language missing maximum constant of numeric types!

Rick Johnson rantingrickjohnson at gmail.com
Sat Feb 25 15:35:52 EST 2012


On Feb 25, 11:54 am, MRAB <pyt... at mrabarnett.plus.com> wrote:
> [...]
> That should be:
> if maxlength is not None and len(string) <= maxlength:

Using "imaginary" infinity values defiles the intuitive nature of your
code. What is more intuitive?

def confine_length(string, maxlength=INFINITY):
    if string.length < maxlength:
        do_something()

def confine_length(string, maxlength=None):
    if maxlength is not None and len(string) <= maxlength:
        do_something()



More information about the Python-list mailing list