A very simple class with a constructor. : Class Constructor « Class « Python






A very simple class with a constructor.

A very simple class with a constructor.


class Student:
     def __init__ (self, name, age, gender):
         self.name   = name
         self.age    = age
         self.gender = gender
 
s = Student("Your Name", 20, "f")
print s

print s.age


           
       








Related examples in the same category

1.Empty Class constructor
2.Constructors DemoConstructors Demo
3.A class may define a special method named __init__()A class may define a special method named __init__()
4.A Simple Logger ClassA Simple Logger Class