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

2019-06-23 Thread Chris Angelico
On Mon, Jun 24, 2019 at 2:44 PM Andrew Barnert via Python-ideas wrote: > But dict displays, that could be confusing. Do you have to pass-value the > key, or the value, or either of the two, or both consistently? If the key, > does that short-circuit the value expression? So I think you’re

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

2019-06-23 Thread Andrew Barnert via Python-ideas
On Jun 23, 2019, at 19:57, MRAB wrote: > >> On 2019-06-24 02:43, Andrew Barnert wrote: >> On Jun 23, 2019, at 13:33, MRAB wrote: >> >> > Finally, under "For consideration: alternative syntaxes", my offering >> > would be: >> > > expr if condition1 and not condition2 else pass >> >> This

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

2019-06-23 Thread MRAB
On 2019-06-24 02:43, Andrew Barnert wrote: On Jun 23, 2019, at 13:33, MRAB wrote: > Finally, under "For consideration: alternative syntaxes", my offering would be: > > expr if condition1 and not condition2 else pass This seems a lot more tenable than the original proposal. The “unless”

[Python-ideas] Re: Make $ a valid identifier and a singleton

2019-06-23 Thread Andrew Barnert via Python-ideas
On Jun 23, 2019, at 17:01, Steven D'Aprano wrote: > >> On Sun, Jun 23, 2019 at 03:22:37PM -0400, James Lu wrote: >> Make $ a valid identifier and a singleton. >> >> $ is a useful placeholder in []. >> >> Possible function partial syntax: >> >> def foo(x, y): >>print(x, y) >> >>

[Python-ideas] Re: Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-06-23 Thread Steven D'Aprano
On Sat, Jun 22, 2019 at 12:14:02PM -0400, James Lu wrote: > If a function that tends to return a context manager returns None, > that should not mean an error occurred. I suppose that *technically* this is true. It might be designed to return a context manager or None. But: 1. Because of the

[Python-ideas] Re: Make $ a valid identifier and a singleton

2019-06-23 Thread Steven D'Aprano
On Sun, Jun 23, 2019 at 03:22:37PM -0400, James Lu wrote: > Make $ a valid identifier and a singleton. > > $ is a useful placeholder in []. > > Possible function partial syntax: > > def foo(x, y): > print(x, y) > > partialized = foo[$, 10] I don't think that creating partial functions is

[Python-ideas] Re: Make $ a valid identifier and a singleton

2019-06-23 Thread Robert Vanden Eynde
I used "..." in my lib to do that : from funcoperators import bracket @bracket def foo(x, y): print(x, y) partialized = foo[..., 10] partialized(5) https://pypi.org/project/funcoperators/ Le dim. 23 juin 2019 à 21:34, James Lu a écrit : > > Make $ a valid identifier and a singleton. > > >

[Python-ideas] Make $ a valid identifier and a singleton

2019-06-23 Thread James Lu
Make $ a valid identifier and a singleton. $ is a useful placeholder in []. Possible function partial syntax: def foo(x, y): print(x, y) partialized = foo[$, 10] partialized(5) # => 5 10 ___ Python-ideas mailing list -- python-ideas@python.org

[Python-ideas] Re: Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-06-23 Thread Chris Angelico
On Mon, Jun 24, 2019 at 4:03 AM James Lu wrote: > > If a function that tends to return a context manager returns None, that > should not mean an error occurred. If an error or unexpected condition > occurred, an exception should be thrown. Errors and exceptions should result > in the code

[Python-ideas] Re: Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-06-23 Thread James Lu
If a function that tends to return a context manager returns None, that should not mean an error occurred. If an error or unexpected condition occurred, an exception should be thrown. Errors and exceptions should result in the code within the with statement not executing. We could add a new