[Edu-sig] new python // and /
Andrew Harrington
aharrin at luc.edu
Fri May 26 16:40:10 CEST 2006
On // and /,
I neglected to mention that in Python 2.4 you can already use / for real
division in any file where the top line imports from future:
from __future__ import division
Andrew Harrington wrote:
>As I gear up to write or translate lessons for Crunchy Frog, I would
>like feedback on one general issue:
>// -- the new integer division operator.
>
>// is already legal in Python 2.4, though / still means the same thing
>for integers. That is to change in Python 2.5, that is already in alpha
>2:
>/ as integer division will able to be set to mean the old operator or
>always mean real division (I forget which is the default in 2.5).
>
>I think this is an excellent change in Python. I would encourage using
>// for integer division in all newly written lessons. There is the
>issue in 2.4 that you still have to go through an extra cast if you want
>real division,
>x = 5
>y = 3
>real_quotient = float(x)/y
>
>but there is nothing for that at the moment
>
>
>
--
Andrew N. Harrington
Computer Science Department Undergraduate Program Director
Loyola University Chicago http://www.cs.luc.edu/~anh
512B Lewis Towers (office) Office Phone: 312-915-7982
Snail mail to Lewis Towers 416 Dept. Fax: 312-915-7998
820 North Michigan Avenue aharrin at luc.edu
Chicago, Illinois 60611
More information about the Edu-sig
mailing list