PyWart: Language missing maximum constant of numeric types!
Rick Johnson
rantingrickjohnson at gmail.com
Fri Feb 24 10:25:21 EST 2012
More information about the Python-list mailing list
Fri Feb 24 10:25:21 EST 2012
- Previous message (by thread): PyWart: Language missing maximum constant of numeric types!
- Next message (by thread): PyWart: Language missing maximum constant of numeric types!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Feb 24, 8:25 am, Neil Cerutti <ne... at norwich.edu> wrote: > > What Python needs is some constant that can be compared to ANY > > numeric type and that constant will ALWAYS be larger! > > What's the point of that? > > The only time I've naively pined for such a thing is when > misapplying C idioms for finding a minimum value. The best use case is for default arguments to constructors or func/ meths. If you set the argument to INFINITY instead of -1 (or some other dumb string value to mean "unlimited") you can omit a useless conditional block later. Observe: if maxlength == -1 # unlimited length: keep_going() elif len(object) < maxlength: stop() # because we reached the limit I see tons and tons of old Python code that uses -1 as an "unlimited" value, where positive numbers are meant to constrain dome value. I have always found that to be intuitive; hence my question.
- Previous message (by thread): PyWart: Language missing maximum constant of numeric types!
- Next message (by thread): PyWart: Language missing maximum constant of numeric types!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list