On 2023-01-19 at 12:59:21 -0500,
Thomas Passin <li...@tompassin.net> wrote:

> Well, it's an art, not a science [...]

+1

> # Create a plot
> g2 = (
>       ggplot(df2,
>       aes('Days Since Jan 22',  # Comments can clarify these params
>       + geom_point(size=.1, color='blue') # size, color params optional
>       + theme_bw() # Optional theme (background, grid color, ...)
>      )

You've got a comma followed by a plus sign in there, so I'm not exactly
sure where the parameters to which function begin and end.

When it starts to look like this, I begin breaking out the parameters:

label = 'Days Since Jan 22'
size = geom_point(size=.1, color='blue')
theme = theme_bw()
g2 = ggplot(df2, aes(label, size, theme))

> # Compose a long string:
> msg = ('A very long line .....\n'
>       + 'Another long bit of text ....'
>       + 'plus another ....'
>       )

If all the pieces are constants, then Python will concatenate them for
you:

msg = ('A very long line .....\n'
       'Another long bit of text ....'
       'plus another')

You can even mix in "f" strings:

msg = ('long line\n'
       f'left text {name} right text'
       'more here')

But watch out for missing spaces between the pieces!  :-)

> The PEP-8 rules are good, but they can't cover all cases perfectly.

Some the PEP-8 rules are debatable.  Regardless, they can't cover all
cases perfectly.  (IOW, we agree on the bit that's relevant to this
thread.)
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to