On Thursday, September 19, 2013, Vittorio Spina wrote:

> ciao,
> che sappiate esiste un modo piĆ¹ elegante per evitare quello che segue?
>     x = UnCertaFunzioneCheRitornaINT()
>     if x>67: x=67
>     if x<-67: x=-67
>

from math import copysign

>> x = get_value_of_X()
>> if not -67 < x < 67:
...      x = copysign(67,x)

Che ne dici? !-)


-- 
valerio
_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a