Creating Class in Python

class Employee:
    #these are the instance variables

    #This is a function definition.
        #the keyword "self" is MUST!It is similar to "this" in java.It says that this method belongs to Employee class.(explicitly saying)
    #"__init__() is the constructor in python.

    def __init__(self,name,sal):;
        print "instance created";

    #a normal method
    def display(self):
        print "*"*20;
        print "Name:",;
        print "Salary:",self.sal;
        print "*"*20;

#class ends

#creating class instance and storing in variable "temp_var"
#display the values


instance created
Name: max
Salary: 10000

About PraveenMax
My Interests: ------------------ Programming , Drawing & Music

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: