String and function esthetics #16375
Replies: 4 comments
-
Only in a different way clumsy:
|
Beta Was this translation helpful? Give feedback.
-
Yeah I personally agree it's pretty ugly like this. Often I define my multiline strings at global context just to avoid this. Alternatively:
|
Beta Was this translation helpful? Give feedback.
-
In CPython you'd typically use the standard library def test():
s = dedent("""\
blahblah
blahblah
blahblah
""")
print(s) assuming you were willing to pay the runtime cost. But apparently That said, if it's constant do what @andrewleech suggested and make it a module-level string. |
Beta Was this translation helpful? Give feedback.
-
I use global variables now at module level, that seems to me the most elegant solution.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I love the clear structure of Python.
One thing however hurts my feelings.
Example:
This is not beautiful.
For me the whole string definition should be indented.
Is there a way to do it more elegantly?
Beta Was this translation helpful? Give feedback.
All reactions