Re: [Python-ideas] What are the strong use cases for str.rindex()? (John Lin)

2019-04-23 Thread Thautwarm Zhao
IMO, there're lots of use cases in parsing related stuffs, which requires rindex a lot, say, when you have generated a tokenizer which might across multiple lines: line 8: X """ line 9: line 10: """ In this case, we need to extract 2 tokens X and , a multiline whitespace string. After getting

Re: [Python-ideas] Add recordlcass to collections module

2018-09-01 Thread Thautwarm Zhao
> > > -- Forwarded message -- > From: Martin Bammer > To: python-ideas@python.org > Cc: > Bcc: > Date: Sat, 1 Sep 2018 09:47:04 +0200 > Subject: [Python-ideas] Add recordlcass to collections module > Hi, > > what about adding recordclass > (https://bitbucket.org/intellimath/recordc

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-17 Thread Thautwarm Zhao
. Back to the topic, this thread seems to be closed now, and in my opinion `:=` could be synthetically the best. 2018-04-17 15:11 GMT+08:00 Mikhail V : > On Tue, Apr 17, 2018 at 6:09 AM, Thautwarm Zhao > wrote: > > > > > > 3) "target ? expr" (where ? is some o

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-16 Thread Thautwarm Zhao
> We have ways of cheating a bit if we want to reinterpret the semantics > of something that nevertheless parses cleanly - while the parser is > limited to single token lookahead, it's straightforward for the > subsequent code generation stage to look a single level down in the > parse tree and se

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-15 Thread Thautwarm Zhao
ference.com/w/cpp/algorithm/inclusive_scan > > * exclusive_scan() is like inclusive_scan(), but _requires_ an "init" > argument (which is not returned). > > http://en.cppreference.com/w/cpp/algorithm/exclusive_scan > > * accumulate() is like Python's functools.reduc

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-15 Thread Thautwarm Zhao
> > > 0. > > while (items[i := i+1] := read_next_item()) is not None: > print(r'%d/%d' % (i, len(items)), end='\r') > > 1. > > while (read_next_item() -> items[(i+1) -> i]) is not None: > print(r'%d/%d' % (i, len(items)), end='\r') > > 2. > > while (item := read_next_item()) is not None: >

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-15 Thread Thautwarm Zhao
> To me, "from" strongly suggests that an element is being obtained from a container/collection of > elements. This is how I conceptualize "from module import name": "name" refers to an object > INSIDE the module, not the module itself. If I saw > > if (match from pattern.search(data)) is not None:

Re: [Python-ideas] PEP 572: Assignment Expressions (post #4)

2018-04-12 Thread Thautwarm Zhao
ar:= function() is None else var.method() > > Still not bad looking. > > On Thu, Apr 12, 2018, 11:01 PM Thautwarm Zhao > wrote: > >> >> > You're looking at a very early commit there. I suggest looking at the >> > most recent commits on one of two branch

Re: [Python-ideas] PEP 572: Assignment Expressions (post #4)

2018-04-12 Thread Thautwarm Zhao
> You're looking at a very early commit there. I suggest looking at the > most recent commits on one of two branches: https://github.com/Rosuav/cpython/blob/statement-local- variables/Grammar/Grammar https://github.com/Rosuav/cpython/blob/assignment- expressions/Grammar/Grammar > Those are the tw

Re: [Python-ideas] PEP 572: Assignment Expressions (post #4)

2018-04-12 Thread Thautwarm Zhao
(because `test` is the top expr). testlist_comp: (test|star_expr) ( comp_for | 'as' NAME | (',' (test|star_expr))* [','] ) It seems that if we're to support expression assignment, `as` binding should be declined. To be honest I feel upset because I think `expr as n

Re: [Python-ideas] Python-ideas Digest, Vol 137, Issue 67

2018-04-12 Thread Thautwarm Zhao
> Makes sense. However, couldn't you prevent that by giving with > priority over the binding ? As in "(with simple_cm) as value", where > we consider the "as" as binding operator instead of part of the with > statement ? Sure, you could commit suicide by parenthesis, but by > default it'd do exact

Re: [Python-ideas] Python-ideas Digest, Vol 137, Issue 40

2018-04-10 Thread Thautwarm Zhao
f Python-ideas digest..." > > Today's Topics: > >1. Re: Is there any idea about dictionary destructing? > (Steven D'Aprano) >2. Re: Is there any idea about dictionary destructing? > (Jacco van Dorp) >3. Re: Start argument for itertools.acc

Re: [Python-ideas] Is there any idea about dictionary destructing?

2018-04-10 Thread Thautwarm Zhao
Your library seems difficult to extract values from nested dictionary, and when the key is not an identifier it's also embarrassed. For sure we can have a library using graphql syntax to extract data from the dict of any schema, but that's not my point. I'm focused on the consistency of the lan

[Python-ideas] Fwd: Is there any idea about dictionary destructing?

2018-04-09 Thread Thautwarm Zhao
I'm sorry that I didn't send a copy of the discussions here. -- Forwarded message ------ From: Thautwarm Zhao Date: 2018-04-09 1:24 GMT+08:00 Subject: Re: [Python-ideas] Is there any idea about dictionary destructing? To: "Eric V. Smith" Thank you, Eric. Your