Unindenting multi line strings in Python

preview_player
Показать описание


00:00 Manually dedenting multi-line strings
01:11 Mind your newlines
01:26 Combining dedent with strip to make the code more readable
02:13 dedent maintains relative indentation levels
Рекомендации по теме
Комментарии
Автор

Great stuff! Thanks for all your help since 2017! 5+ years of python morsels made me one of the most skilled python developers in my organization.

ahmedzouari
Автор

Very useful video, but a better way to format the final code would be:

```py
def copyright():
print(
dedent(
"""
Copyright (c) 1991-2000 ACME Corp
All Rights Reserved.

Copyright (c) 2000-2030 Cyberdyne
All Rights Reserved.
"""
).strip('\n')
)
```

sandipdas
visit shbcf.ru