Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python dedent

# Basic syntax:
from textwrap import dedent
print(dedent("""
	Text for which you want to remove
    leading whitespace when printed
    """))
# Note, IMO it's mostly useful for keeping your code nicely formatted
#	while still printing messages left-justified without leading whitespace

# Example usage:
# Say you have code like:
if __name__ == '__main__':
	if True:
    	print("""
            Make sure the user
            knows this.
            """)
# when you run your script, that text will be printed with the leading
# whitespace, which is gross.

# You could print it without whitespace by restructuring your code like:
if __name__ == '__main__':
	if True:
    	print("""
Make sure the user
knows this.
            """)
# but that screws up the readability of your code.

# Instead, with dedent you can do this and print without the leading whitespace
if __name__ == '__main__':
	if True:
    	print(dedent("""
			Make sure the user
			knows this.
            """))
Comment

PREVIOUS NEXT
Code Example
Python :: reset index pandas 
Python :: python opens windows store 
Python :: como deixar todas as letras maiusculas no python 
Python :: python des 
Python :: enumerate in python 
Python :: how to import numpy array in python 
Python :: python control browse mouse selenium 
Python :: python print to stderr 
Python :: pandas filter on range of values 
Python :: sample datafra,e PYTHON 
Python :: how to sort values in python from dictionary to list 
Python :: add role discord .py 
Python :: python - make a copy of a df 
Python :: how to reverse a list in python 
Python :: limpiar consola en python 
Python :: get ip address in django 
Python :: python list of all tkinter events 
Python :: python colorama example 
Python :: how to invert a list in python 
Python :: discord get user slash command 
Python :: turn list of tuples into list 
Python :: jupyter notebook make new lines 
Python :: create a list of characters python 
Python :: pandas datetime.time 
Python :: get stock data in python 
Python :: read pdf py 
Python :: python delete file with extension 
Python :: python tkinter askopenfile 
Python :: django template for range 
Python :: python live video streaming flask 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =