Skip to main content

Posts

Showing posts with the label Python

Installing pyodbc on ubuntu

Installing pyodbc is straight forward but if  getting     "error: command 'gcc' failed with exit status 1"  when installing pyodbc, make sure you have installed  requirements  as below. sudo apt-get install unixODBC-dev g++ pip install pyodbc

Installing Python Imaging Library(PIL) on ubuntu

Install required packages sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev python-dev Fixing the lib path sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib Install the PIL pip install pil If getting "ImportError: No module named PIL" on importing Image module also try from PIL import Image If not using virtualenv "$ sudo apt-get install python-imaging" will also install pil for the system.

First-class object

Is the on which can dynamically be created, destroyed at runtime during the execution of program,and pass as an argument to other functions. I n some languages like javascript and python functions are also first class objects. Ex. Passing function as an argument in Python:            >>> def op(a,b,fun):             return fun(a,b)     >>> def sum(a,b):             return a+b     >>> op(1,2,sum)     3 Ex. Dynamically defined function in javascript: var supriseMe = function () { alert("Boo!"); supriseMe = function () { alert(" boooooooo!"); }; }; // using the self-defining function supriseMe(); // Boo! supriseMe(); // boooooboo!