On Wed, Aug 28, 2019 at 10:01:25PM -0000, [email protected] wrote:
> > you have something that looks like a kind of string czt'...'
> > but is really a function call that might return absolutely
> > anything at all;
>
> This is kinda the whole point.
Yes, I understand that. And that's one of the reasons why I think that
this is a bad idea.
Since Python is limited to ASCII syntax, we only have a small number of
symbols suitable for delimiters. With such a small number available,
- parentheses () are used for grouping and function calls;
- square brackets [] are used for lists and subscripting;
- curly brackets {} are used for dicts and sets;
- quote marks are used for bytes and strings;
And with your proposal:
- quote marks are also used for function calls, but only a limited
subset of function calls (those which take a single string literal
argument).
Across a large majority of languages, it is traditional and common to
use round brackets for grouping and function calls, and square and curly
brackets for collections. There are a handful of languages, like
Mathematica, which use [] for function calls.
> I understand, of course, how the
> idea of a string-that-is-not-a-string may sound blasphemous,
Its not a matter of blasphemy. It's a matter of readability and
clarity.
> however I invite you to look at this from a different perspective.
>
> Today's date is 2019-08-28. The date is a moment in time, or
> perhaps a point in the calendar, but it is certainly not a string.
> How do we write this date in Python? As
> `datetime("2019-08-28")`. We are forced to put the date into
> a string and pass that string into a function to create an actual
> datetime object.
We are "forced" to write that are we? Have you ever tried it?
py> from datetime import datetime
py> datetime("2019-08-28")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: an integer is required (got type str)
> With this proposal the code would look something like
> `dt"2019-08-28"`. You're right, it's not a string anymore. But
> it *should not* have been a string to begin with, we only used
> a string there because Python didn't offer us any other way.
py> datetime(2019, 8, 28)
datetime.datetime(2019, 8, 28, 0, 0)
It is difficult to take your argument seriously when so much of it rests
on things which aren't true.
--
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/RFAZPMCGCPO4JOHLBHLTE5KNCA5RP6LN/
Code of Conduct: http://python.org/psf/codeofconduct/