python

Python methods for formatting output

Method Str() :

This method returns a string representation for the given variable.

Methods ljust() and rjsut() : 

  • ljust method returns a left justified string with appropriate padding on right side.
  • rjust method returns a right justified string with appropriate padding on left side.

Method format():

Can be used to embed list of sub strings into a main string.

Examples:

Python installing a package as a non root user, with an example openpyxl installation.

In this article I will list down the steps that are needed to install a python package being a non root user. As an example I will show the installation process for “openpyxl”  package.

Step1: Download the package using “wget” or directly visiting the package’s official downloads page.

Python Mako template using dictionaries and arrays

Templating is a common technique used to avoid repetitive coding, also used to separate data from logic. Mako is one of the popular python template engines. In this tutorial I will show an example of Mako template that is used to constructs an "Invoice" form using dictionaries and arrays. Also a python script is given that can process this Mako template with dictionaries and arrays.