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/2002-June/025724.html below:

[Python-Dev] Indexing builtin sequences with objects which supply __int__

[Python-Dev] Indexing builtin sequences with objects which supply __int__ [Python-Dev] Indexing builtin sequences with objects which supply __int__Guido van Rossum guido@python.org
Thu, 20 Jun 2002 16:53:12 -0400
> There has been some recent interest in the Numeric/numarray community 
> for using array objects as indices
> for builtin sequences.  I know this has come up before, but to make 
> myself clear, the basic idea is to make the
> following work:
> 
> class C:
>     def __int__(self):
>           return 5
> 
> object = C()
> 
> l = "Another feature..."
> 
> print l[object]
> "h"
> 
> Are there any plans (or interest) for developing Python in this direction?

I'm concerned that this will also make floats acceptable as indices
(since they have an __int__ method) and this would cause atrocities
like

print "hello"[3.5]

to work.

--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