why won't slicing lists raise IndexError?

Alexandre Brault abrault at mapgears.com
Wed Dec 6 19:39:23 EST 2017


process() wasn't defined either, nor were n and seq and yet you're not 
complaining about them.

It seems it was clear to everyone but you that seq was a sequence 
defined elsewhere, n was an index defined elsewhere, and both process 
and do_without_item were functions defined elsewhere.

And even if you want to be so incredibly pedantic that do_without_item 
(and only do_without_item, because the rest of the code fragment seems 
to get your seal of approval) is not defined, your "functioning 
equivalent" is still not equivalent, because the original code would 
have raised a NameError that yours doesn't.


On 2017-12-06 7:05 PM, Rick Johnson wrote:
> Python wrote:
>
> [...]
>
>> THIS IS FALSE.  CALLING A FUNCTION
> What *FUNCTION*?
>
> You think you can just slap a function-y looking symbol
> willy-nilly in the middle of a chunk of code and then have
> it "magically" transform into a python function object?
>
>      >>> do_without_item()
>
>      Traceback (most recent call last):
>        File "<pyshell#0>", line 1, in <module>
>          do_without_item()
>      NameError: name 'do_without_item' is not defined
>      >>> foo()
>
>      Traceback (most recent call last):
>        File "<pyshell#1>", line 1, in <module>
>          foo()
>      NameError: name 'foo' is not defined
>      >>> bar()
>
>      Traceback (most recent call last):
>        File "<pyshell#2>", line 1, in <module>
>          bar()
>      NameError: name 'bar' is not defined
>
> if "do_without_item()" had been defined, then you could call
> it a function. But until you do, it's just a NameError.




More information about the Python-list mailing list