At long last...

C

Carl Banks

Tuples will have an index method in Python 2.6.

I promise I won't indiscriminately use tuples for homogenous data.
Honest. Scout's honor. Cross my heart.


Carl Banks
 
T

Terry Reedy

Carl said:
Tuples will have an index method in Python 2.6.

I promise I won't indiscriminately use tuples for homogenous data.
Honest. Scout's honor. Cross my heart.

Use them as you want. This change came about because .index was
included in the 3.0 Sequence ABC (abstract base class) and tuple was
included as a sequence, so .... something had to give. The result was
tuple getting the full suite of immutable sequence methods. And then
there was no good reason to not backport ;-).

tjr
 
C

Carl Banks

Use them as you want. This change came about because .index was
included in the 3.0 Sequence ABC (abstract base class) and tuple was
included as a sequence, so .... something had to give. The result was
tuple getting the full suite of immutable sequence methods. And then
there was no good reason to not backport ;-).

The last time I needed index on a tuple was in fact for partially non-
homogenous data. I forget why, but I needed to treat arguments after
a certain value different from the front arguments. So I wanted to do
something like:

def something(*args):
firstspecial = args.index(0)

'Cept I couldn't.


Carl Banks
 
D

Dan Bishop

The last time I needed index on a tuple was in fact for partially non-
homogenous data.  I forget why, but I needed to treat arguments after
a certain value different from the front arguments.  So I wanted to do
something like:

def something(*args):
    firstspecial = args.index(0)

'Cept I couldn't.

Why didn't you just use a list inside the tuple?
 
C

Carl Banks

Why didn't you just use a list inside the tuple?

I don't remember, but knowing myself I was probably implementing some
sort of declarative function that I would call 200 times with hand-
entered data to build some kind of dataset.

Normally I would not design functions like that, but when "ease of
data entry" is the predominant concern I will do all kinds of hacky
stuff.


Carl Banks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top