New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
readline and zero based indexing #51035
Comments
why is it that the zeroth readline history item is seemingly always james@work:~$ python
Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline
>>> readline.get_history_item(0)
>>> readline.get_history_item(0) is None
True
>>>
james@work:~$ |
Please ask questions on, for instance, the python-list (c.l.p). If you find evidence that this is actually a bug, please supply. My *guess* is that history lists are 1-based and Python conforms to that. |
I'd guess the same. Most of the readline module is just a thin wrapper Interestingly, the Apple-supplied python (2.6.1) in OS X 10.6 does have |
@mark: thanks for the comment; i suppose we should investigate why and |
i found this: |
I wonder if changing the base now would cause problems. |
Changing to feature request: I'm fairly certain that this isn't a bug (i.e., it's working as designed). It's possible to use the readline module non-interactively, so it's probably a safe bet that there's at least some code out there that does so. I'd vote to reject this; I agree it would have been nicer if indexing had started from 0 originally, but the 1-based indexing doesn't really seem like a big deal. |
It's an incompatible change; it would definitely break my code, however I think it should be wishlisted for an API-break release like 3.5 or 4.0 or something like that. IMHO, the bindings should be "pythonic", even if the underlying library isn't. In addition, maybe we could add a readline.set_zero_based_indexing() function? I could write a patch for this perhaps... |
A patch would be useful: I don't think this issue is going to go anywhere without one. One of the reasons I'm reluctant to mess with the readline module more than necessary is that it's historically been fairly fragile: it has to work not only with a number of different GNU readline versions, but also with libedit on OS X and BSD (and OS X universal builds add an extra layer of complexity), and there have been a number of readline-related build problems in the past. |
Postscript: I'm also opposed to the idea of 'optional' zero-based indexing. This just seems like a crazy level of micro control to me. Better to have just the one way way to do it, even if it isn't quite pythonic. |
I do not see a change as being accepted. It would not add any new function but probably break code, if not habits, for the sake of consistency that would have been nice. |
I'd be writing a patch which would allow a programmer the option to explicitly use/instantiate the library in a zero-based way. This way throughout their particular program, the indexing of elements could be consistent. Not having this causes you to have to reason differently about which parts should be list[i+1] versions list[i]. Would this be reasonable? _J |
I think not. Mark already stated his opposition to “a crazy level of micro control”. Such a patch would not be trivial but would not bring much. I hope you’ll find other bugs that motivate you for a patch! :) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: