[Python-ideas] Re: Notation for subscripts.

2021-08-22 Thread Matsuoka Takuo
Dear Developers, After some findings and further thoughts through this thread, I have formulated a proposal as follows. (I thank everyone who has commented in this thread). For the necessary definitions, please look at https://docs.python.org/3/reference/expressions.html#subscriptions https://d

[Python-ideas] Re: Notation for subscripts.

2021-08-21 Thread Matsuoka Takuo
Dear ChrisA, Steve, Thank you for your comments. ChrisA, it was off the main topic, but for me, the issue was just one of wording in the exception message. It's good to hear changes to wording can be done without compatibility concerns. I'll find out about merge request suggested by Stephen J. Tu

[Python-ideas] Re: Notation for subscripts.

2021-08-19 Thread Stephen J. Turnbull
Matsuoka Takuo writes: > >>> *(1,2), > (1, 2) Yes, this works, and now that I see you just want that to work in "a[*(1,2),]", I agree, I don't know why that is a syntax error. This works, of course: t = *(1,2), a[t] (in the sense that if a is a sequence you get a TypeError because th

[Python-ideas] Re: Notation for subscripts.

2021-08-19 Thread Chris Angelico
On Thu, Aug 19, 2021 at 11:27 PM Matsuoka Takuo wrote: > > Dear Steve, > > Thank you for your detailed explanation. > > > > (i.e., it can be mistyped as "s[1,2,]" but without SyntaxError this > > > time). It would at least be consistent if we got SyntaxError in > > > both cases (namely, the syn

[Python-ideas] Re: Notation for subscripts.

2021-08-19 Thread Matsuoka Takuo
Dear Steve, Thank you for your detailed explanation. > > (i.e., it can be mistyped as "s[1,2,]" but without SyntaxError this > > time). It would at least be consistent if we got SyntaxError in > > both cases (namely, the syntax allowed only a single Python > > expression here), but if we don'

[Python-ideas] Re: Notation for subscripts.

2021-08-18 Thread Matsuoka Takuo
Dear Guido van Rossum, Thank you for bringing the PEP's to my attention. The idea of PEP 637 on a[*x] is different from my idea. The PEP's idea appears making subscription analogous to function calls. In the end, a[*x] would have been equivalent to a[tuple(x)] if the PEP had been adopted. a[*

[Python-ideas] Re: Notation for subscripts.

2021-08-18 Thread Matsuoka Takuo
Matsuoka Takuo : > > Now, is "1,2," more boxed up than "*(1,2)," is? The *current* rule > surely says the former is a tuple at some places and the latter > is not, Actually, this was wrong. First of all, >>> *(1,2), (1, 2) Moreover, while the Language Reference says return_stmt ::= "return"

[Python-ideas] Re: Notation for subscripts.

2021-08-16 Thread Mxzixl
I believe this is useful since this syntax is developed in some libraries as an internal DSL. At least I have seen it in pandas, a library handling tables. df[(df['a'] < df['b']) & (df['b'] < df['c'])]     df[~df['a'].isin(df['b'])] df[df['b'].isin(df['a']) & (df['c'] < df['d'])] More exampl

[Python-ideas] Re: Notation for subscripts.

2021-08-16 Thread Stephen J. Turnbull
Matsuoka Takuo writes: > I don't see any parenthesis nor bracket around "1,2,". Parentheses are not part of tuple display syntax, with the exception of "()", the empty tuple. Parenthesis are needed for tuple displays only to group the display in the context of a larger expression. This is my

[Python-ideas] Re: Notation for subscripts.

2021-08-15 Thread Guido van Rossum
Have you seen PEP 637? IIRC it has discussions on a[] and a[*x]. Note that it was rejected, but the idea of a[*x] is being resurrected for PEP 646. On Fri, Aug 13, 2021 at 5:43 AM Matsuoka Takuo wrote: > Dear Developers, > > Given a subscriptable object s, the intended rule for the notation for

[Python-ideas] Re: Notation for subscripts.

2021-08-15 Thread Matsuoka Takuo
Dear Steve, Thank you for your thoughts. To be precise, the sequence of letters "*(1,2)" is not actually a "starred expression" in the sense of the Python Language, but e.g., "*(1,2), " is. (A comma is trailing.) Please check the definitions here: https://docs.python.org/3/reference/expressions.

[Python-ideas] Re: Notation for subscripts.

2021-08-14 Thread Stephen J. Turnbull
Matsuoka Takuo writes: > Let me clarify the issue. An optional starred expression (denoted > "[starred_expression]" in the specification of the syntax) is a > natural generalization of an expression list (which is not necessarily > an expression in the Python sense) in the sense that use of th

[Python-ideas] Re: Notation for subscripts.

2021-08-14 Thread Matsuoka Takuo
Thanks 2QdxY4RzWzUUiLuE for your thoughtful response. I shouldn't have used the word "expression" since it was going to be taken as a Python term. Let me clarify the issue. An optional starred expression (denoted "[starred_expression]" in the specification of the syntax) is a natural generalizatio

[Python-ideas] Re: Notation for subscripts.

2021-08-13 Thread 2QdxY4RzWzUUiLuE
On 2021-08-13 at 23:18:29 +1100, Matsuoka Takuo wrote: > Given a subscriptable object s, the intended rule for the notation for > getting an item of s seems that, for any expression {e}, such as > "x, ", > s[{e}] > (i.e., s[x, ] if {e} is "x, ") means the same as > s[({e})] If e is an expres