[Python-ideas] Re: Make the global/nonlocal keyword a prefix

2021-11-14 Thread Chris Angelico
On Mon, Nov 15, 2021 at 5:05 AM Christopher Barker wrote: > > On Sun, Nov 14, 2021 at 6:05 AM Steven D'Aprano wrote: >> >> global a = 3 > > > The issue i see is that Python doesn't have declarations. So you could use > the name, a in multiple places. what would this mean: > > a = 34 > > glob

[Python-ideas] Re: Allow syntax "func(arg=x if condition)"

2021-11-14 Thread Chris Angelico
On Mon, Nov 15, 2021 at 4:57 AM Christopher Barker wrote: > > On Sun, Nov 14, 2021 at 9:51 AM Chris Angelico wrote: >> >> Also, it's entirely possible that future >> versions of Python will have a concept of optional arguments that >> don't *have* defaults, > > > As noticed earlier in this threa

[Python-ideas] Re: Make the global/nonlocal keyword a prefix

2021-11-14 Thread Christopher Barker
On Sun, Nov 14, 2021 at 6:05 AM Steven D'Aprano wrote: > global a = 3 > The issue i see is that Python doesn't have declarations. So you could use the name, a in multiple places. what would this mean: a = 34 global a = 0 would it mean that the first a was loca, and the second local? or wo

[Python-ideas] Re: Allow syntax "func(arg=x if condition)"

2021-11-14 Thread Christopher Barker
On Sun, Nov 14, 2021 at 9:51 AM Chris Angelico wrote: > Also, it's entirely possible that future > versions of Python will have a concept of optional arguments that > don't *have* defaults, As noticed earlier in this thread, it seems it's currently possible to do that with functions written in

[Python-ideas] Re: Allow syntax "func(arg=x if condition)"

2021-11-14 Thread Chris Angelico
On Mon, Nov 15, 2021 at 4:18 AM Peter O'Connor wrote: > > On Mon, Mar 22, 2021 at 1:28 PM Caleb Donovick > wrote: >> >> ... One could do something like: >> ``` >> def fun(a, b=0): ... >> def wraps_fun(args, b=inspect.signature(fun).parameters['b'].default): ... >> ``` >> But I would hardly call

[Python-ideas] Re: Allow syntax "func(arg=x if condition)"

2021-11-14 Thread Peter O'Connor
On Mon, Mar 22, 2021 at 1:28 PM Caleb Donovick wrote: > ... One could do something like: > ``` > def fun(a, b=0): ... > def wraps_fun(args, b=inspect.signature(fun).parameters['b'].default): ... > ``` > But I would hardly call that clear. > > Caleb > I like this approach too - it just needs a c

[Python-ideas] Re: Make the global/nonlocal keyword a prefix

2021-11-14 Thread Steven D'Aprano
Hi Jonathan, Does this global/nonlocal prefix idea of yours allow us to do anything new that we can't do now? At first glance, it looks like all it will do is increase the complexity of the language, making it harder for the interpreter and third party tools to identify globals, without any in

[Python-ideas] Make the global/nonlocal keyword a prefix

2021-11-14 Thread Jonathan Sh.
Usually when we want to make a variable/def/class etc global, we can just declare `global v` at the beginning, but I feel like there could be a better way to do that. So my idea is to allow doing stuff like `global a = 3` or `nonlocal def x(): ...` or even `for global i in []: ...` in add