[Tutor] Appropriate use of assignment expression

Tristin Cara Moone tcm2118 at columbia.edu
Sat Nov 20 12:14:36 EST 2021


On Sat, Nov 20, 2021 at 12:04 PM Alan Gauld via Tutor <tutor at python.org>
wrote:

> On 20/11/2021 14:33, Richard Damon wrote:
>
> >> Personally, I've been burned so many times with assignments
> >> inside tests in C that I try my best to avoid it
>
> > One BIG thing to point out is that C leaves a lot of details about the
> > order things happen to up to the implementation, so this sort of
> > statement might not work there.
>
> To be honest there are many features of Python and its
> implementation of the walrus assignment that are tighter
> than C so my fears are not really justified, it's just
> painful experience making me wary. (And to be fair C++
> has tightened up many of C's shortcomings in those
> areas too)
>
> > Personally, I tend to like to decompose into clearly defined functions
>
> Exactly, and that's what I tend to do in places where
> many might use the walrus. It's more expressive, easier
> to debug and extend.
>
> The walrus is one of those 'nice to have' things that is
> mainly used by those who think there are prizes for
> writing the shortest code. It's just not true.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


-- 
Thank you.


More information about the Tutor mailing list