PyWart: Language missing maximum constant of numeric types!
Rick Johnson
rantingrickjohnson at gmail.com
Fri Feb 24 09:14:04 EST 2012
On Feb 24, 7:55 am, Mark Lawrence <breamore... at yahoo.co.uk> wrote:
> Do you want to test for something that is larger than infinity?
Not exactly. I want to set a constant that has a value of infinity and
then do comparisons against the constant.
##################
# Hypothetical 1 #
##################
def confine(string, maxlength=INFINITY):
return string[:maxlength]
py> confine('123')
'123'
py> confine('123', 1)
'1'
##################
# Hypothetical 2 #
##################
def confine(string, maxlength=INFINITY):
if len(string) < maxlength:
do_something()
else:
twiddle_thumbs()
More information about the Python-list
mailing list