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

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 >

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 <mikhail...@gmail.com>: > On Tue, Apr 17, 2018 at 6:09 AM, Thautwarm Zhao <yaoxiansa...@gmail.com> > wrote: > > > > &g

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

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

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

2018-04-12 Thread Thautwarm Zhao
ne if var:= function() is None else var.method() > > Still not bad looking. > > On Thu, Apr 12, 2018, 11:01 PM Thautwarm Zhao <yaoxiansa...@gmail.com> > wrote: > >> >> > You're looking at a very early commit there. I suggest looking at the >> > most

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

2018-04-12 Thread Thautwarm Zhao
d in a general expression, just as `test` is the top of expression, an expression using `as` binding must be in the structure `test`. In other words, if you write with expr as name: # do stuff Without doubt it's equivalent to `with (expr as name)`. Or you want to completely change the grammar

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

2018-04-11 Thread Thautwarm Zhao
ted dicts. > And if you dont actually want to destruct (tuples and lists aren't > destroyed either), just use __getitem__ access instead of pop. But pop cannot work for a nested case. Feel free to end this topic. thautwarm 2018-04-10 23:20 GMT+08:00 <python-ideas-requ...@python.org>

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

[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 <yaoxiansa...@gmail.com> Date: 2018-04-09 1:24 GMT+08:00 Subject: Re: [Python-ideas] Is there any idea about dictionary destructing? To: "Eric V. Smith" <

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

2018-04-07 Thread thautwarm
= name -> true | _ -> false let recordX = { Name = "Parker"; ID = 10 } let isMatched1 = IsMatchByName recordX "Parker" let isMatched2 = IsMatchByName recordX "Hartono" All of them partially destructs(or matches) a dictionary. thautwarm