On Wed, 27 Jul 2022 at 21:54, Mathew Elman <mathew.el...@ocado.com> wrote: > > I don't see why you couldn't. I guess what they do depends if any of these > have defaults? Which I think they do not in this case, right? > If they were non vanilla dictionaries that had a default e.g. > > class SomeDict(dict): > def __getitem__(self, item=None): > return super().__getitem__(item) > > def __contains__(self, item=None): > return super().__contains__(item)
So Undefined would trigger a default, but only if there is one? > print(b[1]) would still print Undefined because print's first argument > doesn't have a default. But print doesn't have a first argument - it accepts *args. So Undefined still counts as an argument, except when there's a default, at which point it counts as a non-argument? > a in c would be False. That is VERY surprising behaviour. For literally any other object, that would be True. But then, it would be surprising in other ways if Undefined behaved like a normal object. > c[a] would return c[None], which would raise an error here because None isn't > in the mapping Again, very surprising, if putting a value into a mapping doesn't result in that value being in the mapping. > Again, I am not pro this idea, just answering the questions you're asking as > I see them :) Yeah. I think you're doing a great job of showing why this is a bad idea :) ChrisA _______________________________________________ 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/M54T7JRN5AWT3KGWSXNYVRHDQUVDADAE/ Code of Conduct: http://python.org/psf/codeofconduct/