[Python-ideas] Re: Assign-in-place operator

2019-06-05 Thread Yanghao Hua
On Tue, Jun 4, 2019 at 12:47 PM Jeroen Demeyer wrote: > > I'd like to get rid of all the signal and HDL stuff (whatever that > means) in this thread, so I think what the original poster really wants > is an "assign in place" operator. Basically, something like += or *= but > without the arithmetic

[Python-ideas] Re: Operator as first class citizens -- like in scala -- or yet another new operator?

2019-06-05 Thread Yanghao Hua
On Wed, Jun 5, 2019 at 12:52 AM Greg Ewing wrote: > > Yanghao Hua wrote: > > Did Guido say "user defined syntax" or "user defined operator"? > > ... for me defining new operator is different > > To my mind it's not that much different. A reader encountering an > unfamiliar operator is pretty much

[Python-ideas] Re: Operator as first class citizens -- like in scala -- or yet another new operator?

2019-06-05 Thread Paul Moore
On Wed, 5 Jun 2019 at 09:06, Yanghao Hua wrote: > With my very limited understanding of cpython internals (at least when > I implement <==) it seems cpython is searching for an operator and > then translates it into a method call on the objects Not really. The valid operators are hard coded into

[Python-ideas] Re: Operator as first class citizens -- like in scala -- or yet another new operator?

2019-06-05 Thread Chris Angelico
On Wed, Jun 5, 2019 at 6:08 PM Yanghao Hua wrote: > > On Wed, Jun 5, 2019 at 12:52 AM Greg Ewing > wrote: > > > > Yanghao Hua wrote: > > > Did Guido say "user defined syntax" or "user defined operator"? > > > ... for me defining new operator is different > > > > To my mind it's not that much di

[Python-ideas] Python-ideas] Re: Operator as first class citizens -- like in scala -- or yet another new operator?

2019-06-05 Thread Angus Hollands
Regarding this operator proposal, I also think we can still do this comfortably with the existing Python syntax. The problem that I have is I don't really understand what the *problem* is that you're trying to solve. It would be helpful if you had some explanation on that front. I see there was som

[Python-ideas] Adding context manager interface to contextvars.Token

2019-06-05 Thread Christoph Groth
It seems that the following idea has not been raised here before. If it has been, I'd be grateful for a pointer to the relevant discussion. The idea is: how about adding context manager interface (__enter__ and __exit__ methods) to the contextvars.Token type? This would allow code like this:

[Python-ideas] python-ideas is now running on Mailman 3

2019-06-05 Thread Brett Cannon
https://mail.python.org/mailman3/lists/python-ideas.python.org/ ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s Code of Conduct: h

[Python-ideas] Re: Adding context manager interface to contextvars.Token

2019-06-05 Thread Yury Selivanov
Hi Christoph, Adding context manager protocol support to contextvars.Token was considered when PEP 567 was discussed. There wasn't a strong argument against that; however we decided not to immediately add it because context variables is a relatively low-level API. In you case, you can simply wra

[Python-ideas] Re: python-ideas is now running on Mailman 3

2019-06-05 Thread Pradyun Gedam
On Wed, 5 Jun 2019 at 10:52 PM, Brett Cannon wrote: > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > %(web_pa

[Python-ideas] Re: python-ideas is now running on Mailman 3

2019-06-05 Thread Christoph Groth
Thanks for moving python-ideas to Mailman 3. To me this is the best of two worlds. I noticed a small problem: it seems that identation of code snippets gets lost in the web view. For example: def inc(a): return a + 1 Could something be done about this? Python-Ideas mailing list -- python-d

[Python-ideas] Re: Adding context manager interface to contextvars.Token

2019-06-05 Thread Christoph Groth
Hi Yury, thanks for the quick reply. Yury Selivanov wrote: > Adding context manager protocol support to contextvars.Token was > considered when PEP 567 was discussed. There wasn't a strong argument > against that; however we decided not to immediately add it because > context variables is a rel

[Python-ideas] Re: python-ideas is now running on Mailman 3

2019-06-05 Thread Abhilash Raj
Hi, You could open a bug report about it at https://gitlab.com/mailman/hyperkitty/issues Would be nice if you could include the raw message that you sent, or if you posted from the web, then just mention that. There is rich text support on the way, but there are some quirks remaining to be fi

[Python-ideas] Re: Adding context manager interface to contextvars.Token

2019-06-05 Thread Yury Selivanov
On Wed, Jun 5, 2019 at 6:22 PM Christoph Groth wrote: [..] > I'm aware of this possibility, however it is not suitable for the use > case that I have in mind (configuration variables), because it requires > too much code for each variable. > > Of course one could wrap your example inside a factory

[Python-ideas] Re: Adding context manager interface to contextvars.Token

2019-06-05 Thread Yonatan Zunger
I had a similar recent need, with a bit more on top of it, and solved it with this slightly insane library. (Alas, I haven't figured out a good way to make it act as a true subtype of UnderlyingType yet) import contextvars from typing import Any, Generic, TypeVar UnderlyingType = TypeVar('Underly

[Python-ideas] Re: Assign-in-place operator

2019-06-05 Thread Ryan Gonzalez
Think of it more like indexing a range. Say you have: L[:] = M[:] Which is the same as: L[0:len(L)] = M[0:len(M)] Which mentally you can think of like: L[0], L[1],...L[len(L)] = M[0],M[1],...M[len(M)] Slicing is just indexing that represents more than one element, and if you think about it l