Jon Ribbens <jon+use...@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. -- https://mail.python.org/mailman/listinfo/python-list