[Tutor] OOPS Problem
sudhanshu gautam
sudhanshu9252 at gmail.com
Mon Apr 13 22:36:04 CEST 2009
I am reading python since last 15 days ,read some basics of python , Last
night was reading about the OOPS concepts ,but getting some problems , going
to discuss with you people.
MY CODE :
I made a class with the name student that prints simply name of the student
as well as his roll_no also, pasting code here .
code:
class student:
def __init__(self,name,roll_no):
self.name=name
self.roll_no
def display(self):
print 'name',self.name,'roll_no',self.roll_no
s1=student("sudhanshu",21)
s2=student("rahul",22)
s1.display()
s2.display()
student is a class name
problem 1: Why we always use first method as a __init__
problem 2: why we put first argument as a self inside the __init__
parentheses
if __init__ is a constructor then how it works.
How I can run this code , working on ubuntu : but when write inside the
terminal python filename.py but it shows nothing
regards
password
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090414/69dbe99f/attachment.htm>
More information about the Tutor
mailing list