Programming for the Web has become a hot topic since the rise of “Web 2.0”, which focuses on user-generated content on web sites. It has always been possible to use Python for creating web sites, but it was a rather tedious task. Therefore, many frameworks and helper tools have been created to assist developers in creating faster and more robust sites.
3 Apr, 2019
Examples of time subtraction in Python. Using the best date-time library called Pendulum. You can use add or subtract to alter time.
11 Mar, 2019
HMAC (a keyed-hash message authentication code) is used to verify API request. HMAC is constructed by concatenating form parameter key and value pairs into a string ordered by alphabetic order of the...
27 Feb, 2017
You can save files to Amazon with Python using library called boto. Boto is a Python interface to Amazon Web Services and we need just a tiny part of it. If you have very large files you have to...
20 Feb, 2017
To get custom columns from a query you can use the with_entities() method to restrict which columns you'd like to return in the result. Use label() method to give AS value to your query. To use...
10 Feb, 2017
Snippet shows you how to write to temporary directory. You can either write a single file, or do stuff in a directory. In any case you should remove the files and folders after you have done your...
27 Jan, 2017
Get timestamp in seconds as integer in Python using the time library.
19 May, 2016
This snippet shows you how to convert po files to mo files. Po is the raw plain-text translation file with key value storage format. Mo files are compiled po files, binary format allows you to read...
11 May, 2016
Read and decode json file in Python. You can use the same method for regular json strings.
11 May, 2016
Pretty print array, meaning that you print array, dictionary, object or any non string format in human-friendly way. This is great for terminal / command line. When you are looking for something for...
4 May, 2016
This short snippet shows how to define an array in Python.
3 Feb, 2016
Get current time with timezone in Python. This can be achieved using a library named arrow. It's a datetime library for correct and easy calculations using only one library.
2 Feb, 2016
Generating hmac involves using "private" key. So you you need to "double encode it". In python you can achieve it using two libraries hashlib and hmac.
1 Feb, 2016
Add column collation to column creation in SQLAlchemy. Optional, a column-level collation for use in DDL and CAST expressions. Renders using the COLLATE keyword supported by SQLite, MySQL, and...
29 Jan, 2016
Using SQLAlchemy to create table columns. To use numeric data types you have to use mysql dialects.
7 Nov, 2015
Check if a python module is installed or not on the system. The simplest way to do it is in terminal.