A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/033038.html below:

Passing floats to "i" parser marker

[Python-Dev] Re: Passing floats to "i" parser markerGuido van Rossum guido@python.org
Wed, 05 Feb 2003 16:48:56 -0500
> for my personal extension code, i actually benefit from the features
> of automatic float-to-int conversion.

Can you explain the situation more?  What's your application?  Where
do the floats come from?

> in the same context, i'm wondering if the "s" formatting should change 
> also? currently you can pass unicode or string objects and they get 
> properly converted. i use so little of unicode my input may be totally 
> invalid, but it seems float->int is approximate to unicode->string ?

No, when the unicode->string conversion would lose information, an
exception is raised.

> lastly, as a contrived example. to insert an item in the middle of a 
> list is pretty simple,
>      mylist.insert(len(mylist)/2, myval)
> with the new integer division, this would pass a float into an integer 
> argment(?). just food for thought, wondering what the expected behaviour 
> of this would be?

You should be writing len(mylist)//2.

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4