pytoolz / pytoolz/toolz

last indexerror: tuple index out of range

Open
#424 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
280
Avg merge
6d 17h
Merged PRs (30d)
4

Description

Here is a reproducible example:

foo = zip([1,2,3],[4,5,6])
last(foo)
last(foo)

The output in my repl looks like this

In[43]: foo = zip([1,2,3],[4,5,6])
In[44]: last(foo)
Out[44]: (3, 6)
In[45]: last(foo)
Traceback (most recent call last):
  File "/Users/mlindon/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2963, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-45-06bc2d3f7f9e>", line 1, in <module>
    last(foo)
  File "/Users/mlindon/anaconda3/lib/python3.6/site-packages/toolz/itertoolz.py", line 398, in last
    return tail(1, seq)[0]
IndexError: tuple index out of range

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with toolz/itertoolz.py at the last function and inspect how it delegates to tail(1, seq). Reproduce the example with an exhausted zip iterator, then check the surrounding tests or add a focused regression test to establish the expected behavior for repeated calls. Done means the exhausted-iterator case has a defined, tested result.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.