I don't do twitter, so hadn't seen Raymond's comment. But I agree that `{*()}` is too-clever-by-half. Moreover, it's the same character count as `set()`, so it doesn't even save anything.
Using five characters to create an empty `set()` really isn't that many. I do that all the time. Proposals to get that down to three characters don't feel like any big win. Actually, I've largely gotten in the habit of writing `list()` and `dict()` as well when I want to start with empty ones. I suppose the fact I do that is influenced by having to do it with `set()`; but even beyond that, I find it jumps out in intent more than the display forms. The pattern of "Create an empty collection, then add stuff in a loop" is quite common, and emphasizing which type of collection is being used is useful. Moreover, the type might be `Queue()`, or `deque()` or `Counter()` as well, and I don't expect or want literals for every possible collection. On Fri, Apr 9, 2021 at 5:43 PM Ricky Teachey <ri...@teachey.org> wrote: > On Fri, Apr 9, 2021 at 3:20 AM Serhiy Storchaka <storch...@gmail.com> > wrote: > >> 08.04.21 19:58, ucod...@gmail.com пише: >> > I would like to propose adding literal syntax to allow creation of an >> empty set without the need to call the type constructor. I believe the best >> choice for such a literal, and one that has been proposed before, is `{,}`. >> >> You can now use `{*()}` as a syntax for empty set. >> > > Interestingly, Raymond Hettinger recently had a post on twitter > specifically deriding this usage as obfuscatory, and expressing his > preference that people not do it (and use set() instead). > > https://twitter.com/raymondh/status/1372376414184296448 > > I tend to agree with him on that... I have no opinion on whether set > should be given its own "empty repr literal", but I don't think {*()} is a > useful suggestion to give people who want one. > > --- > Ricky. > > "I've never met a Kentucky man who wasn't either thinking about going home > or actually going home." - Happy Chandler > _______________________________________________ > 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/5MVX7DYTMYRGZNTAFAW4DQXQH4YLZHTO/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- The dead increasingly dominate and strangle both the living and the not-yet born. Vampiric capital and undead corporate persons abuse the lives and control the thoughts of homo faber. Ideas, once born, become abortifacients against new conceptions.
_______________________________________________ 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/EVX6ZFBNFQJ4NCW4X5QEA52WN3QJDLIF/ Code of Conduct: http://python.org/psf/codeofconduct/