PyWart: Language missing maximum constant of numeric types!
WolfgangMeiners01 at web.de
Sun Feb 26 14:38:37 CET 2012
Am 26.02.12 14:16, schrieb Wolfgang Meiners:
> I just had a closer look at it. It seems to be more complicated than i
> thougth: You will have to write
Obviously not close enough, as i just learned.
> def confine_length(string, maxlength=None):
> if maxlength: # maxlength exists, comparison possible
if maxlength is not None: # maxlength exists, comparison possible
> if len(string) <= maxlength:
> else: # maxlength does not exist, so always do something
> you migth also write
> def confine_length(str, maxlength=None):
> do_it = (len(str) <= maxlength) if maxlength else True
do_it = (len(str) <= maxlength) if maxlength is not None else True
> if do_it:
I hope, it's correct now.
More information about the Python-list