stilo Python - continuação de linha com string
Ao tentar obedecer às regras do estilo python, configurei meus editores para um máximo de 79 col
No PEP, recomenda o uso da continuação implícita do python entre colchetes, parênteses e chaves. No entanto, ao lidar com seqüências de caracteres quando atingi o limite de colunas, fica um pouco estranh
or exemplo, tentando usar uma multilinha
mystr = """Why, hello there
wonderful stackoverflow people!"""
Retornar
"Why, hello there\nwonderful stackoverflow people!"
Isso funciona
mystr = "Why, hello there \
wonderful stackoverflow people!"
Como retorna isso:
"Why, hello there wonderful stackoverflow people!"
Mas, quando a instrução é recuada alguns blocos, isso parece estranho:
do stuff:
and more stuff:
and even some more stuff:
mystr = "Why, hello there \
wonderful stackoverflow people!"
Se você tentar recuar a segunda linha:
do stuff:
and more stuff:
and even some more stuff:
mystr = "Why, hello there \
wonderful stackoverflow people!"
Sua sequência termina como:
"Why, hello there wonderful stackoverflow people!"
A única maneira que encontrei para contornar isso é:
do stuff:
and more stuff:
and even some more stuff:
mystr = "Why, hello there" \
"wonderful stackoverflow people!"
O que eu mais gosto, mas também é um pouco desconfortável para os olhos, pois parece que há uma corda no meio do nada. Isso produzirá o apropriado:
"Why, hello there wonderful stackoverflow people!"
Então, minha pergunta é - quais são as recomendações de algumas pessoas sobre como fazer isso e há algo que estou perdendo no guia de estilo que mostra como devo fazer isso?
Obrigado