Tuesday 9 June 2015

How to add folders in a git hub repository?

Follow the normal way of creating files inside your repo and put '/' after your folder name , it will automatically create a folder.

You can follow the github blog for more info :
https://github.com/blog/1436-moving-and-renaming-files-on-github

Sunday 30 March 2014

What is __init__ and self in python and what purpose they serve?


This is one question that every python newbie comes across.

Let's take a code snippet

class Test(object):
 
        def __init__(self):
                self.name = 'This is a test code'

        def test_method(self):
                print self.name

The __init__ () method in python is responsible for creating the instance of a class (here Test class). This is the method that get's called whenever you create an instance of a class. This basically acts as a constructor for a python class.
The argument list in __init() is the list of argument passed in to the constructor to initialize the argument.

When we say self.name the variable name is bound to the object of Test Class. These types of variables are the part of object and have the same life as of the obect. We can consider them as the instance variable which are available for the class that is beyond the scope of any function.

Similarly the name of a function that is qualified with 'self' refers to a method function that is part of the class definition.



 


Sunday 16 June 2013

Installing PIP in Windows

This is one of the toughest things I have come across recently. Installing PIP on linux is altogether different thing. But I really had a hard time while installing PIP on windows. There are so many suggestion available on the internet that hardly worked for me. But the solution I found out is worth sharing.

What is PIP?

--> PIP is a package management system  which is used to install python software packages directly from your command line.

Steps to install PIP :
Download pip windows installer from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip.
Download the ez_setup.py script and run it by downloading from  https://pypi.python.org/pypi/setuptools/0.7.2#windows
Run the script.
Once installation is complete, you will find an easy_install .exe program in your Python/scripts subdirectory.
Run the pip installer.
Add C:\Python27\Scripts to you path and you are good to go.