- It seems like "foo?[bar]" could be easily confused with "foo??[bar]". I don't think it's immediately obvious to a newcomer which spelling corresponds to which usage, and getting the two mixed up seems like the sort of thing that could cause all sorts of subtle bugs.
- We can already easily get the same functionality using standard Python. E.g., instead of doing foo?["bar"]?[0]?["baz"], we could do lookup(foo, "bar", 0, "baz") where lookup is a function that looks roughly like this:
def lookup(item, *parts):
for part in parts:
if item is None:
return None
item = item[parts]
return item
Of course, we could probably create the same sort of function to replace foo?.bar (albeit less ergonomically), but unlike foo?[bar], there's no possibility for confusion: doing foo??.bar will never be a valid Python expression.
- One counter-argument against removing foo?[bar] is that it would make expression that need both safe index and attribute lookups look weird -- you'd sometimes be using the "lookup" function described above (or something similar) and sometimes using ".?". However, I'd argue that these sorts of scenarios are relatively rare in practice, and that if you really need to deal with a bunch of code that requires you to use both forms of safe navigation, your code is likely already becoming pretty unreadable and should be rewritten -- maybe split up into multiple lines or something, or maybe just redesigned from scratch so you don't need to constantly manage a mess of Nones.
More broadly, I think I agree with the sentiment some other people have that Python has acquired a lot of new features in a relatively short period of time, and that it would be nice to have some cooldown to let tooling and other implementations catch up. In that regard, I'd personally be happy if we didn't implement this PEP or just deferred it again. But if we *are* moving forward with it, I think it's worth trying to simplify it as much as possible/try and make it orthogonal with existing Python features.
(But of course, I'm just some random person on the internet, so IDK if my opinion counts for much.)
Regards,
-- Michael