Define a class, which have a class parameter and have a same instance parameter.


Topic: Define a class, which have a class parameter and have a same instance parameter.

Solution

class Person:    
    name = "Person"
    def __init__(self, name = None):
        self.name = name
jeffrey = Person("Jeffrey")
print "%s name is %s" % (Person.name, jeffrey.name)
nico = Person()
nico.name = "Nico"
print "%s name is %s" % (Person.name, nico.name)



List all Python Programs