how to convert an integer to a float?

Ben Finney bignose+hates-spam at benfinney.id.au
Tue Feb 27 21:35:21 EST 2007


Please don't top-post; instead, reply below the lines you're
responding to, and trim any irrelevant lines from the original.

Subscriber123 <subscriber123 at gmail.com> writes:

> How did the new division ever get approved?!

By being introduced as a PEP, which is now numbered PEP 238.

    <URL:http://www.python.org/dev/peps/pep-0238/>

> That's not pythonic! What if you then need to divide two integers
> and find an element in a list or dict?

Then your code is dependent on ambiguous behaviour which has changed
in newer Python versions.

As described in the above document, the '//' operator will
unambiguously request floor division, even in older versions of
Python.

> I know that at the moment it is not implemented unless imported from
> __future__, but I expect that it eventually might be.

Please read PEP 238 to see the implementation plan.

> That would be a problem with backwards compatibility.

The older Python versions aren't going away. Anyone who wants their
old code to work with new versions of Python has a responsibility to
see what parts of their code need to be updated.

-- 
 \      "My roommate got a pet elephant. Then it got lost. It's in the |
  `\                           apartment somewhere."  -- Steven Wright |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list