[Tutor] A Question about coding style

Tristin Cara Moone tcm2118 at columbia.edu
Thu Sep 23 08:29:25 EDT 2021


On Thursday, September 23, 2021, Cameron Simpson <cs at cskk.id.au> wrote:

> On 23Sep2021 09:34, Albert-Jan Roskam <sjeik_appie at hotmail.com> wrote:
> >     > This style is uncommon. On a personal
> >
> >     > basis I tend to use styles like this if I have several very short
> >     test/action pairs. Example:
> >
> >         for x, y, z in some-3-tuples...:
> >             if x < 0: x = 0
> >             if y > 5: y = 6
> >             if y + z > 10: z /= 2
> >
> >   ==>> I don't have Python here, but won't the "black" code prettifier
> >   correct this? It's in my git hooks
>
> "correct"? Reformat, sure. "correct" is in the eye of the beholder, and
> 'black" is a very unforgiving beholder. I use yapf for my personal code,
> and it would might fold the lines above because it uses weights to make
> some of these decisions.
>
> "black" enforces a very rigid interpretation of PEP8. "yapf" is more
> flexible, and has many knobs to adjust its behaviour - its defaults are
> basicly PEP8 and indeed you can define a style as "start with PEP8 but
> make these changes", which is how I've defined my personal style for
> "yapf".
>
> Cheers,
> Cameron Simpson <cs at cskk.id.au>
> _______________________________________________
> 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