Archive
Archive for July, 2014
print a text by specifying the width via a variable
July 11, 2014
Leave a comment
Problem
You want to print a text using a certain width that you want to specify via a variable. Running example:
$ ./test.py Width: 10 ' World' Width: 20 ' World'
Solution
for _ in range(2):
width = int(raw_input("Width: "))
print("'{0:>{w}}'".format("World", w=width))
The sign ‘>‘ can be omitted. It simply means “align to the right”.
Tip from here.
Categories: python
string format, variable width
Django show_urls formatter
July 11, 2014
Leave a comment
Today I wrote a little script to beautify the output of the command “manage.py show_urls“. The script is available on GitHub here. For more info, visit the previous GitHub link.
Screenshots
Normal usage:
$ ./manage.py show_urls
Adding the beautifier:
$ ./manage.py show_urls | fmt.py
Categories: django, python
beautifier, django-extensions, formatter, manage.py, show_urls
awesome Python
July 2, 2014
1 comment
“awesome-python is a curated list of awesome Python frameworks, libraries and software. Inspired by awesome-php.”
Have you ever wondered what kind of packages to use for geolocation for instance? Here you will find the answer.
The good thing is that the libraries are put in categories.
Categories: python


