#module with one function and one dictionary def greeting(name): printr("Hello", +name) person = {"name" : "John", "age" : 36, "country" : "Norway"} #package class Mammals: def __int__(self): public() self.member = ['Tiger', 'Elephant', 'Lion'] def printmembers(self): print('printing members of the mammals class') for member in self.members: print('\t%s' %member) class Birds: def __int__(self): public() self.members = ['sparrow', 'robin', 'duck'] def printmembers(self): print('printing members of birds class') for members in self.members: print('\t%s' %members) from Animals import Mammals from Animals import Birds myMammal = Mammals() myMammal.printMembers() myBirds = Birds() myBird,printMembers()
#!/usr/bin/env python # Import classes from Animals import Mammals from Animals import Birds # Create mammal myMammal = Mammals() myMammal.printMembers() # Create bird myBird = Birds() myBird.printMembers()
from Animals import Mammals from Animals import Birds mymammal = Mammals() mymammal.printMembers() mybirds = Birds() mybirds.printMembers()
# Import classes from your brans new package from Animals import Mammals from Animals import Birds # Create an object of Mammala class & call a method of it myMammal = Mammals.Mammals() myMammal.printMembers() # Create an object o fBirds class & call a method of it myBird = Birds.Birds() myBird.printMembers()
''' Created on Dec 7, 2015 @author: sanjeev ''' from Animals import Mammals from Animals import Birds myMammal = Mammals() myMammal.printMembers() # Create an object of Birds class & call a method of it myBird = Birds() myBird.printMembers()
from Animals import Mammals from Animals import Birds dog = Mammals() dog.printMembers() duck = Birds() duck.printMembers()
# Import classes from your brand new package from Animals import Mammals from Animals import Birds Birds.myt() print ('\n') # Create an object of Mammals class & call a method of it myMammal = Mammals.Mammal() myMammal.printMembers() # Create an object of Birds class & call a method of it myBird = Birds.Bird() myBird.printMembers()