python

What packages are installed/available in my python?

Often times, I need to know what modules are currently installed and available in my python VM. Here are two commands for this… 1. run “help(‘modules’)” within your python interpreter. This will list all the modules including the standard packages that comes with Python 2. If you need to know only the modules installed by

Read on »

How to find a python library’s version?

Often times we need to check the version of a python library installed. I see there is no standard attribute convention for it. Most often it is  __version__ or Version or version or ver or Ver etc.,  So I use the dir command on the module to find out the exact attribute name for the

Read on »

How to use *args and **kwargs?

Often times you may notice python codes having  function signatures with both *args and **kwargs. This nice article explains how to use these both when calling functions and within function body.

Read on »

Steps to install Scrapy.

The following steps assumes that you already have python installed. To make your installation easy the steps recommend using easy_install tool. Install Scrapy 1. Download and install easy_install tool from cheeseshop . 2. Easy install “zope.interface” 3. Download and install Twisted 10.2.0 from Twisted site 4. Easy install “lxml” 5. Easy install “pyOpenSSL” 6. Easy

Read on »

Split a list using python zip function

I just found this trick. Say if you want to split a list with i number of elements into lists with j number of elements. It can easily be done with one liner using the python zip function. You just need to unzip the list specifying the “j”. See python documentation on zip for more

Read on »

Combine items in two list to form dictionary(map)

People love python because it has solutions built in for problems most frequently faced by developers. Python’s zip is one such thing. Gist: https://gist.github.com/rajaramanathan/a4e1b5b3531fd2b2cfab You would most probably need this in scenarios like csv file reading where the first row in the file is list of column names and subsequent are values. You know well

Read on »

Python objects and types

I’m one of the guy who needs to know the internals of a machine before using it. I can’t help it but that is my very nature. The following article that I refer to is not for faint heart (meaning beginners to programming or python) and is by far the best i’ve found ever that

Read on »