Datatype of non-negative values

Dirk Hagemann usenet at mail-2-me.com
Thu Feb 10 10:52:46 EST 2005


A result smaller than 0 should be just invalid.

I'd like to work with "try" and "except" like this:
value=20
try:
    value=value-23
except:
    print 'value is smaller than 23'

Now it should run into the "except".

Dirk Hagemann


Larry Bates <lbates at syscononline.com> wrote in message news:<0q2dnRpPIs3Jo5ffRVn-rw at comcast.com>...
> What exactly do you want to happen when result
> would be negative?  I'll guess be zero:
> 
> pseudocode:
> 
> x=value
> x=max(x-something, 0)
> 
> That way if it goes negative, it sticks to zero.
> 
> Larry Bates
> 
> 
> Dirk Hagemann wrote:
> > Hi,
> > 
> > Is there a datatype in python which allows no negative values? I
> > subtract several times something from a value and I don't want to chek
> > everytime if this value is still bigger or equal 0.
> > 
> > Thanks for help!
> > Dirk Hagemann



More information about the Python-list mailing list