[... big snip...] On 22Jan2022 01:41, Chris Angelico <ros...@gmail.com> wrote: >On Sat, 22 Jan 2022 at 00:56, Joao S. O. Bueno <jsbu...@python.org.br> wrote: >> At that point, I argue that despite adding still more things to >> the syntax, it is one that will spare time in average than the other >> way around, due to the time people, needing frozensets for >> the first time in any project, waste looking for a literal syntax for them >> only to find out there is not any. > >Have you any stats on this? There is no literal/display syntax for >datetimes, regular expressions, ranges, bytearrays, or a host of other >common types. How often do people reach for a literal syntax for >those? (I say "literal/display" since, technically, dicts have a >display syntax, not a literal, and complex numbers are written as a >constant-folded sum, but in practical terms, those count. The other >types don't even get that.) If frozensets are so special that they >need syntax, why not ranges, which are used far more frequently?
Well, some data. a) if the, for example, f{constant-set-display} syntax is generalisable (notionally, where we generalise it or not), it offers a path to frozen literals for other things via a prefix notation, should be become desirable. b) literal regexps: people use these _all the time_, conceptually. To the latter: Perl has literal regexps, you just write: /regexp-goes-here/ It even has a verbose commentable form of that to aid writing understandable regexps (hahaha!). What, we're not Perl? True, but you see _lots_ of code like this: # apologies if I have the argument order wrong here if re.match('regexp-string', 'target-string'): which effectively relies on the re module's autocaching of regexps to be efficient while skipping the more overt: # top of module foo_re = re.compile('regexp-string'[,options]) .... # in the main code if m := foo_re.match('target-string'): The former is nothing else but a metaphor for a literal regexp. I'm _not_ arguing for regexp literals in Python - IMO they're undesirable, a separate argument. (Note: not "undesired", just undesirable: to be avoided except when they're the right solution.) Cheers, Cameron Simpson <c...@cskk.id.au> _______________________________________________ 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/DCOH4HQ26AU2DJBEBSFUPQSIECLOOSR4/ Code of Conduct: http://python.org/psf/codeofconduct/