[Python-Dev] assignment expressions: an alternative proposal

Ethan Furman ethan at stoneleaf.us
Tue Apr 24 12:03:06 EDT 2018


On 04/24/2018 08:56 AM, Yury Selivanov wrote:
> On Tue, Apr 24, 2018 at 11:51 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
>
>>> When I compare to variables from outer scopes they *usually* are on
>>> the *right* side of '=='.
>>
>>
>> You mean something like
>>
>>    if 2 == x:
>>
>> ?  I never write code like that, and I haven't seen it, either.
>
> Hm. I mean this:
>
>     const = 'something'
>
>     def foo(arg):
>       if arg == const:
>          do something
>
> Note that "const" is on the right side of "==".
>
> Would you write this as
>
>     def foo(arg):
>        if const == arg:
>
> ? ;)

Heh, no.

But I do write this:

   def wrapper(func, some_value):
     value_I_want = process(some_value)
     def wrapped(*args, **kwds):
       if value_I_want == 42:
          ...

--
~Ethan~


More information about the Python-Dev mailing list