On Sep 2, 2019, at 23:50, Philippe Prados <pyt...@prados.fr> wrote: > > Like Kotlin, add a new `?` operator to use syntax like `int?` ou `?int` ? > CONS: It’s not compatible with IPython and Jupyter Lab `?smth` displays help > for symbol `smth` > CONS: With default arguments, `?=` looks... not great > def f(source: str?=def_src, destination: str?=MISSING, param: int?=1): ...
This has a lot more precedents than Kotlin; it’s a widespread spelling across a variety of modern languages. The incompatibility with IPython isn’t that big a deal in practice, for the reasons I explained when I raised the issue in the first place. Using a `?` suffix isn’t just potentially ugly as in your example, it’s also potentially confusing given languages that use `?=` as null-coalescing assignment or equality, not to mention forever closing off the possibility of adding that feature to Python (which was rejected both times I remember it coming up, but people do still occasionally propose it anew). But I don’t think `?` as a prefix has either the ugliness problem or the cross-language confusion problem: def func(source: ?str=def_src, destination: ?str=MISSING): (I mean, it’s still not beautiful, but that’s just the usual brevity vs. familiarity issue, not a matter of having to parse in your head which part of the expression the `?` belongs to.) Also, `?` is a new operator. And it uses up one of the few ASCII symbols that Python hasn’t yet given a meaning to. Which doesn’t rule it out (unless we want to be like Go and explicitly permanently reserve `?` to mean “some unknown future feature that’s so amazing that it’s better than whatever feature you think you want to use it for”), but it does make the hurdle a lot higher than using `~`.
_______________________________________________ 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/ZWQ3PLYH2O4BRWOHQCTDLZIQ7ZOYZJSJ/ Code of Conduct: http://python.org/psf/codeofconduct/