why won't slicing lists raise IndexError?
Python
python at bladeshadow.org
Wed Dec 6 16:11:01 EST 2017
More information about the Python-list mailing list
Wed Dec 6 16:11:01 EST 2017
- Previous message (by thread): why won't slicing lists raise IndexError?
- Next message (by thread): why won't slicing lists raise IndexError?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Dec 05, 2017 at 06:23:04PM -0800, Rick Johnson wrote: > [bunch of old, irrelevant context snipped] > > item = seq[n:n+1] > > if item: > > process(item) > > else: > > do_without_item() > > When Python follows a logic clause like a train skating > along a set of railroad tracks, and finds itself in a *GHOST > TOWN*, that's not an action -- "Steve-o" -- it's a non- > action. Geez, seriously? The snippet is purely academic, obviously not a complete or useful program, intended to illustrate that python can take two different branches depending on whether or not the slicing operation yeilded a non-empty container, using uncomplicated syntax. It effectively serves that purpose. Moreover, in order for the example to make sense, we must assume the existence of unspecified code: The variables need to have been initialized previously, or else the snippet is non-functional. The if conditional would never be reached. We can as easily assume that the hypothetical example continues with other, unspecified code, and that the equally unspecified do_without_item() actually does something, which renders your argument completely invalid and pointless. The whole thing is entirely academic; continuing to argue this is an utter waste of time and bandwidth.
- Previous message (by thread): why won't slicing lists raise IndexError?
- Next message (by thread): why won't slicing lists raise IndexError?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list