[pyar] Int anti-intuitivo

QliX=D! [aka EHB] qlixed en gmail.com
Lun Nov 15 00:47:51 ART 2010


2010/11/15 Sebastian Bassi <sbassi en clubdelarazon.org>:
>>>> int(2)
> 2
>>>> int(2.1)
> 2
>>>> int("2")
> 2
>>>> int("2.1")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ValueError: invalid literal for int() with base 10: '2.1'
> Hubiese esperado que me devuelva 2.


Help on class int in module __builtin__:

class int(object)
|  int(x[, base]) -> integer
|
|  Convert a string or number to an integer, if possible.  A floating point
|  argument will be truncated towards zero (this does not include a string
|  representation of a floating point number!)
[...]

No mucho mas que decir... no?
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20101115/f97420b7/attachment.html>


More information about the pyar mailing list