Oops, didn’t notice this wasn’t Python-ideas — that’s where it should be.
-CHB On Sun, Mar 13, 2022 at 3:44 PM Christopher Barker <python...@gmail.com> wrote: > > Possible solution: >> s = {} # new empty set >> d = {:} # new empty dictionary (the ":" is a reference to key-value pairs) > > > This would be fine for a new language. But completely out of the question > for Python — it would break an enormous amount of code. > > We are in this position because sets are relatively new to Python, and > there are only so many brackets. > > Current workaround at least for consistency: >> l = list() # new empty list >> t = tuple() # new empty tuple >> s = set() # new empty set >> d = dict() # new empty dictionary >> >> However, it doesn't feel right to not be able to initialize an empty set >> as cleanly and consistently as lists, tuples and dictionaries in both forms. > > > It may not “feel” right, but is it that big a deal? There are literally > any number of types that can’t be initialized with a “literal” — so > consistence is not compelling here. set() is (maybe?) the only builtin, but > is initializing and empty set that common? > > Note, there was a recent thread on this list about a literal for frozenset > — I think: > > f{} was proposed— you may want to revive that -and add s{} for an empty > set … > > Though i personally wouldn’t support the idea. > > -CHB > > > > -- > Christopher Barker, PhD (Chris) > > Python Language Consulting > - Teaching > - Scientific Software Development > - Desktop GUI and Web Development > - wxPython, numpy, scipy, Cython > -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/BIFDLW3R4GTWBCS2HYO6JXARI5YDGVBE/ Code of Conduct: http://python.org/psf/codeofconduct/