for / while else doesn't make sense

Ben Bacarisse ben.usenet at bsb.me.uk
Sun May 22 15:51:19 EDT 2016


Jon Ribbens <jon+usenet at unequivocal.co.uk> writes:

<snip>
> No, in Python integers are closed under the standard arithmetic
> operators (+ - * / % **) - except, since Python 3, for "/", which
> is now a special case.

2 ** -1 is 0.5 even in Python 2[*].

I agree with your general point (that floats should not pop up unbidden)
but I don't think you need to exclude the possibly that an operator can
do that.  With perfect hindsight, I think I'd have had the integers
closed under operators +, -, *, //, % and (say) ^, whilst making it
clear that / and ** produce floats.  There's no reason to see this as
being any less explicit that writing 1.0 as a way to make your intent to
use floats explicit.

* Not a Python expert so all I means is that I get 0.5 on my machine and
  I'm assuming that's what Python 2 mandates as the result.

-- 
Ben.



More information about the Python-list mailing list