Newb ??

Alex Martelli aleax at mail.comcast.net
Fri Nov 11 10:10:01 EST 2005


Norman Silverstone <norman at littletank.org> wrote:
   ...
> Incidentally, I am only just starting to learn about functions and have
> not come across the module 're'. Also why is it (lo+hi)//2 and not
> (lo+hi)/2.

Using // ensures truncation, which is what you want. A single / may mean
truncating division in the default legacy/compatibility mode, but with
the new division behavior (which one day will become standard) it means
true division, so that for example 1/2 means 0.5 -- better get used to
the new behavior ASAP (which is why you can ask for new division
behavior with -Qnew on Python's commandline or 'from __future__ import
division' at the top of your module -- to help you get used to it).


Alex



More information about the Python-list mailing list