[Tutor] Strange range and round behaviour
Lee Harr
missive at hotmail.com
Mon Jun 7 22:16:47 CEST 2010
> Just out of curiosity does anyone know why you get a deprecation warning if
> you pass a float to range but if you use round, which returns a float, there
> is no warning?
It has nothing to do with the round.
It's just that the warning is only shown once:
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
>>> range(2.0)
__main__:1: DeprecationWarning: integer argument expected, got float
[0, 1]
>>> range(2.0)
[0, 1]
>>>
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> range(round(2.0))
__main__:1: DeprecationWarning: integer argument expected, got float
[0, 1]
>>> range(round(2.0))
[0, 1]
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969
More information about the Tutor
mailing list