Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-19 Thread Christopher Barker
Also: @something def fun(): ... Is exactly the same as: def fun() ... fun = something(fun) So you can’t make a distinction based whether a given usage is as a decoration. -CHB On Tue, Mar 19, 2019 at 12:26 PM Greg Ewing wrote: > Sylvain MARIE via Python-ideas wrote: > >

Re: [Python-ideas] True and False are singletons

2019-03-19 Thread Cameron Simpson
On 18Mar2019 08:10, Eric Fahlgren wrote: On Mon, Mar 18, 2019 at 7:04 AM Rhodri James wrote: On 18/03/2019 12:19, Richard Damon wrote: > On 3/18/19 7:27 AM, Greg Ewing wrote: >> Juancarlo Añez wrote: >> >>> if settings[MY_KEY] is True: >>> ... >> >> If I saw code like this, it

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-19 Thread Greg Ewing
Sylvain MARIE via Python-ideas wrote: `my_decorator(foo)` when foo is a callable will always look like `@my_decorator` applied to function foo, because that's how the language is designed. I don't think it's worth doing anything to change that. Everywhere else in the language, there's a very

Re: [Python-ideas] Why operators are useful

2019-03-19 Thread Greg Ewing
Antoine Pitrou wrote: You are being idealistic here. MyPy relies on typing hints being available, and sufficiently precise. Yes, but it doesn't require type hints for *everything*. Given enough starting points, it can figure out the rest. Mathematicians rely heavily on their readers being

Re: [Python-ideas] function annotation enhancement

2019-03-19 Thread Jelle Zijlstra
Your proposed syntax is hard to implement, because it would require invasive syntax changes to the language itself. That's probably not worth it. However, there are other ways to achieve what you're looking for that don't require changing the language itself. This issue has some proposals:

[Python-ideas] function annotation enhancement

2019-03-19 Thread Tim Mitchell
I would like to propose an enhancement to function annotations. Here is the motivating use case: When using callbacks I would like to declare the signature once as a type alias and use it to type hint both the function accepting the callback and the callbacks themselves. Currently I can declare

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-19 Thread Chris Angelico
On Wed, Mar 20, 2019 at 12:37 AM Sylvain MARIE via Python-ideas wrote: > > Stephen > > > If the answer is "maybe", IMO PyPI is the right solution for distribution. > > Very wise words, I understand this point. > However as of today it is *not* possible to write such a library in a > complete

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-19 Thread Sylvain MARIE via Python-ideas
Stephen > If the answer is "maybe", IMO PyPI is the right solution for distribution. Very wise words, I understand this point. However as of today it is *not* possible to write such a library in a complete way, without an additional tool from the language itself. Trust me, I tried very hard

Re: [Python-ideas] Why operators are useful

2019-03-19 Thread Antoine Pitrou
On Tue, 19 Mar 2019 10:49:41 +1300 Greg Ewing wrote: > Rémi Lapeyre wrote: > > > You can make "inferences from the way things are used". But the > > comparison with maths stops here, you don’t make such inferences because > > your > > object must be well defined before you start using it. >

Re: [Python-ideas] True and False are singletons

2019-03-19 Thread Serhiy Storchaka
18.03.19 22:52, Wes Turner пише: >>> True = 1   File "", line 1 SyntaxError: can't assign to keyword The error message will be changed in 3.8. >>> True = 1 File "", line 1 SyntaxError: cannot assign to True ___ Python-ideas mailing list

Re: [Python-ideas] True and False are singletons

2019-03-19 Thread Serhiy Storchaka
18.03.19 22:58, Greg Ewing пише: Oleg Broytman wrote:    Three-way (tri state) checkbox. You have to distinguish False and None if the possible valuse are None, False and True. In that case the conventional way to write it would be     if settings[MY_KEY] == True:     ... It's not a