On Fri, Aug 28, 2020 at 5:10 AM Todd <toddr...@gmail.com> wrote:

>
> But I don't see why this is a problem we have to deal with.  The index
> argument can just not be passed at all, and it is up to the class developer
> to pick an appropriate sentinel if needed.
>
>>
>
That is a good point -- any existing ocde (Or new code that doesn't support
keywords) would raise an Error -- though it would be a (TypeError, rather
than a SyntaxError) if no index were passed in. So why not allow it?

This does require some thought about backward compatibility -- as passing
anything other than a single index is now a SyntaxError, most code in teh
wild will not be set up to handle the run time TypeError that might now
arise.

As "proper" exception handling should be close to the operation, and catch
specific Exceptions, most case will probably be fine. But not all. For
example, there might be code in the wild that does
try:
    a_function(something)
except TypeError:
    do_something

And there is something in a_function that uses indexing -- someone messes
with that code, and puts something new in an index that used to be a
SyntaxError and is now a TypeError -- in the past, that wouldn't have even
run, but now it will, and the problem might not be caught in tests because
the TypeError is being handled.

Given that this would be a change from a compile time error to a runtime
error, there is no code that used to work that will break, but it would be
easier to write broken code in certain situations -- maybe not a huge deal,
but worth thinking about.

-CHB
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/OBADMTX3WHU7DLJNYXHBBPOTZRTJUOWR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to