[Python-ideas] Debugging: some problems and possible solutions

Michael Selik mike at selik.org
Wed Oct 3 12:48:58 EDT 2018


On Wed, Oct 3, 2018 at 9:29 AM Anders Hovmöller <boxed at killingar.net> wrote:
>>> foo(=a, =1+bar)
>
>> Unfortunately, that won't help with Jonathan's inital example
>> expression "big_array[5:20]" as it's not a valid keyword.
>
> I didn't understand that. The example you are referring to is
> print('big_array[5:20] =', big_array[5:20])
>
> Nothing is a keyword in that example or in my example. My suggestion is that we could do:
> my_func(=big_array[5:20])
>
> And it would be compile time transformed into
> my_func(**{'big_array[5:20]': big_array[5:20]})
>
> and then my_func is just a normal function:
>
> def my_func(**kwargs):
>      Whatever

You're right, that case will work. I was thinking of

In [1]: foo(a+b=1)
  File "<ipython-input-1-61f24dcb4c20>", line 1
    foo(a+b=1)
       ^
SyntaxError: keyword can't be an expression


More information about the Python-ideas mailing list