Tips to make Python here-documents easier to read

In Python, here-documents are typically written as:

Python


message = """Humpty Dumpty sat on a wall,
Humpty Dumpty had a great fall.
All the king's horses and all the king's men
Couldn't put Humpty together again."""

But don't you think it's a little hard to see? This will make it easier to see.

Python


message = """
Humpty Dumpty sat on a wall,
Humpty Dumpty had a great fall.
All the king's horses and all the king's men
Couldn't put Humpty together again.
"""[1:-1]

It was a little trick.

Recommended Posts

Tips to make Python here-documents easier to read
Expand devicetree source include to make it easier to read
~ Tips for beginners to Python ③ ~
Color Python errors (stack traces) to make them easier to understand
Make the display of Python module exceptions easier to understand
Tips for coding short and easy to read in Python
Join csv normalized by Python pandas to make it easier to check
python tips
python tips
Python Tips
Python tips
Make SikuliX's click function easier to use
How to read pydoc on python interpreter
[Python] How to make a class iterable
Fractal to make and play with Python
Make pypy submission easier with atcoder-cli (python)
Read Python csv and export to txt
Note: Improving annoying prompts to make them easier to read. // Linux prompt change
Memo # 4 for Python beginners to read "Detailed Python Grammar"
Python Conda Tips
How to read a CSV file with Python 2/3
Updated to Python 2.7.9
2. Make import easier
Python debugging tips
I want to make a game with Python
[Python] How to read excel file with pandas
Memo # 3 for Python beginners to read "Detailed Python Grammar"
Python click tips
[Python] How to read data from CIFAR-10 and CIFAR-100
[Bash] Use here-documents to get python power from bash
Try to make a "cryptanalysis" cipher with Python
Memo # 1 for Python beginners to read "Detailed Python Grammar"
Unexpectedly (?) Python tips
"Cython" Tutorial to Make Python Explosive: Basic Configuration
Memo # 2 for Python beginners to read "Detailed Python Grammar"
I read "How to make a hacking lab"
[Blender x Python] How to make an animation
Try to make a dihedral group with Python
How to make Substance Painter Python plugin (Introduction)
[Blender x Python] How to make vertex animation
Memo # 7 for Python beginners to read "Detailed Python Grammar"
I want to make C ++ code from Python code!
Memo # 6 for Python beginners to read "Detailed Python Grammar"
How to make Python faster for beginners [numpy]
How to make Python Interpreter changes in Pycharm
Materials to read when getting started with Python
Memo # 5 for Python beginners to read "Detailed Python Grammar"
"Backport" to python 2
[python] Read data
Lark Basics (Python, Lark to make a shell-like guy)
Tips for Python beginners to use the Scikit-image example for themselves 7 How to make a module
The background of the characters in the text image is overexposed to make it easier to read.
Template of python script to read the contents of the file
[Python] Try to read the cool answer to the FizzBuzz problem
Try to make a command standby tool with python
Explain in detail how to make sounds with python
Continuation ・ I tried to make Slackbot after studying Python3
Read the xml file by referring to the Python tutorial
Tips and precautions when porting MATLAB programs to Python
[Python] How to deal with pandas read_html read error
How to make a Python package using VS Code