On Sun, Jan 16, 2022 at 09:18:40PM +1100, Chris Angelico wrote: > While it's tempting, it does create an awkward distinction. > > f(1, 2, 3) # look up f, call it with parameters > f[1, 2, 3] # look up f, subscript it with paramters > f{1, 2, 3} # construct a frozenset
You forgot f"1, 2, {x+1}" # eval some code and construct a string Not to mention: r(1, 2, 3) # look up r, call it with parameters r[1, 2, 3] # look up r, subscript it r"1, 2, 3" # a string literal > And that means it's going to be a bug magnet. I don't think that f{} will be any more of a bug magnet than f"" and r"" already are. > Are we able to instead make a sort of vector literal? > > <1, 2, 3> Back in the days when Python's parser was LL(1), that wasn't possible. Now that it uses a PEG parser, maybe it is, but is it desirable? Reading this makes my eyes bleed: >>> <1, 2, 3> < <1, 2, 3, 4> True > Unfortunately there aren't many symbols available, and Python's kinda > locked into a habit of using just one at each end (rather than, say, > (<1, 2, 3>) or something), so choices are quite limited. Triple quoted strings say hello :-) {{1, 2, 3}} would work, since that's currently a runtime error. But I prefer the f{} syntax. -- Steve _______________________________________________ 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/7RNS6HALAPTTFAOFCTTUNUNFRYU6EYV3/ Code of Conduct: http://python.org/psf/codeofconduct/