[Python-ideas] Re: `if-unless` expressions in Python

2019-06-06 Thread Robert Vanden Eynde
> print([ > 3, > if False never_called() unless False, > if False never_called() unless False, > 2, > if True 5 unless False, > 4 >]) # => [3, 2, 5, 4] Do you mean this ?Currently what I use is the `*` operator on lists : ``` print([ 3, ] + ([never_called()

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

2019-06-06 Thread Greg Ewing
Stephen J. Turnbull wrote: L[m:m+k] specifies that a list operation will take place on the k elements starting with m. As a value, it makes a new list of references to those elements. Even that is specific to lists. There's no requirement that a RHS slice has to create new references to elemen

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

2019-06-06 Thread Christoph Groth
Yury Selivanov wrote: > On Thu, Jun 6, 2019 at 5:20 PM Christoph Groth > wrote: > [..] > > The other possibility I see would be wrapping ContextVar inside a > > class (like in the example module that I attached to the first post > > in this thread), but that's not a good solution. It requires >

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

2019-06-06 Thread Yury Selivanov
On Thu, Jun 6, 2019 at 5:20 PM Christoph Groth wrote: [..] > The other possibility I see would be wrapping ContextVar inside a class > (like in the example module that I attached to the first post in this > thread), but that's not a good solution. It requires replicating the > complete API, and i

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

2019-06-06 Thread Mark Sapiro
On 6/6/19 12:32 PM, Brett Cannon wrote: > > > On Thu, Jun 6, 2019 at 2:15 AM Paul Moore > Also, on the distutils-sig setup, an extra footer: > > Message archived at > > https://mail.python.org/archives/list/distutils-...@python.org/message/YN3DHLPXVH5RYLV2P4QJFSWHC6KKRGNH/ > >

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

2019-06-06 Thread Christoph Groth
Yury Selivanov wrote: > Christoph Groth wrote: > > Did you consider anything like that? For example, ContextVar could > > accept an optional keyword arg 'validate' that must be a function > > that is then called for each new value, and somehow reports problems > > (by return value or by raising a

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

2019-06-06 Thread Brett Cannon
On Thu, Jun 6, 2019 at 2:15 AM Paul Moore wrote: > On Wed, 5 Jun 2019 at 20:05, Pradyun Gedam wrote: > > > > On Wed, 5 Jun 2019 at 10:52 PM, Brett Cannon wrote: > >> > >> https://mail.python.org/mailman3/lists/python-ideas.python.org/ > >> ___ > >> Py

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

2019-06-06 Thread Yury Selivanov
On Thu, Jun 6, 2019 at 8:04 AM Christoph Groth wrote: > > Yury Selivanov wrote: > > > I suggest you to open an issue on bugs.python.org to implement support > > for context manager protocol for contextvars.Token. I'm not opposed > > to the idea. Keep in mind that Python 3.8 is already in a featu

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

2019-06-06 Thread Mark Sapiro
Christoph Groth wrote: > > 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? See https://gitlab.com/mailman/hyperkitty/issues/239#note_178646125 Python-Ideas

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

2019-06-06 Thread Stephen J. Turnbull
Yanghao Hua writes: > For example, L[:] if appeared at the right hand side, means a copy > (not a reference) of L, but now when appear on the left hand side, it > behaves like an in-place copy. This two isn't it mentally > contradicting each other? No. I suspect you're confused by the specif

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

2019-06-06 Thread Stephen J. Turnbull
> I'll consider doing that once I understand how Hyperkitty's richt text > support works. *sigh* Filed: https://gitlab.com/mailman/hyperkitty/issues/239 Reply-To set to Mailman Developers. Discussion there if you want to work on it. Steve Python-Ideas mailing list -- python-dev(a)python.or

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

2019-06-06 Thread Christoph Groth
Yury Selivanov wrote: > I suggest you to open an issue on bugs.python.org to implement support > for context manager protocol for contextvars.Token. I'm not opposed > to the idea. Keep in mind that Python 3.8 is already in a feature > freeze mode, so the earliest we can get this is Python 3.9.

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

2019-06-06 Thread Christoph Groth
Yonatan Zunger wrote: > 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) > > (...) To me, your trick seems to address a different problem.

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

2019-06-06 Thread Yanghao Hua
On Thu, Jun 6, 2019 at 11:10 AM Angus Hollands wrote: > > I'm not sure if you saw my reply earlier: > https://mail.python.org/archives/list/python-ideas@python.org/thread/B7QPHTQSBVN4NFO3SEVR57AIGYPM3MUM/ > > I proposed some alternative syntax already supported. Yes, saw it ... not sure signal[.

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

2019-06-06 Thread Paul Moore
On Wed, 5 Jun 2019 at 20:05, Pradyun Gedam wrote: > > 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 unsubscr

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

2019-06-06 Thread Angus Hollands
I'm not sure if you saw my reply earlier: https://mail.python.org/archives/list/python-ideas@python.org/thread/B7QPHTQSBVN4NFO3SEVR57AIGYPM3MUM/ I proposed some alternative syntax already supported. Python-Ideas mailing list -- python-dev(a)python.org To unsubscribe send an email to python-ideas-

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

2019-06-06 Thread Christoph Groth
Abhilash Raj wrote: > There is rich text support on the way, but there are some quirks > remaining to be fixed. Is it documented anywhere? I couldn't find anything, only your issue https://gitlab.com/mailman/hyperkitty/issues/225. > You could open a bug report I'll consider doing that once I

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

2019-06-06 Thread Yanghao Hua
On Thu, Jun 6, 2019 at 9:48 AM Chris Angelico wrote: > They have a difference for the built-in list type in that slicing a > list returns a new list with references to the same objects, thus "x = > x[:]" is going to give you an equivalent but distinct list. That's an > important point in some cont

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

2019-06-06 Thread Yanghao Hua
On Wed, Jun 5, 2019 at 11:31 AM Chris Angelico wrote: > Part of the reason you can't just treat the + operator as a method > call is that there are reflected methods. Consider: > > class Int(int): > def __radd__(self, other): > print("You're adding %s to me!" % other) > return

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

2019-06-06 Thread Chris Angelico
On Thu, Jun 6, 2019 at 5:40 PM Yanghao Hua wrote: > > On Thu, Jun 6, 2019 at 6:31 AM Ryan Gonzalez wrote: > > > > 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:

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

2019-06-06 Thread Yanghao Hua
On Thu, Jun 6, 2019 at 6:31 AM Ryan Gonzalez wrote: > > 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 i