Recently I noticed that using modules was a good option to keep my python programming tidy. For getting started, I made one module (named, oop.py) with a single class in it, which looks like below:
#Module named oop
class Team:
    def __init__(self):
            print "class Team initialized"
    def displayTeam(self):
            print "Team name: ", self.name, ",Rank :" , self.rank
    def setTeam(self,name,rank):
            self.name = name
            self.rank = rank
t1 = Team()
t1.setTeam("Man-Utd", 1)
t1.displayTeam()
According to python documentation, if we want to use specific attribute from a module then we use <from module_name> import <attribute> . I wanted to only load the "class Team"
In another python code (named, oop1.py) I simply imported the above module. oop.py is as mentioned below :
#This is oop1.py.          
#Importing module oop
from oop import Team
The output of python oop1.py from terminal was :
class Team initialized
Team name:  Man-Utd ,Rank : 1
By declaring from oop import Team , I was expecting to load only class definition. Why are those extra lines t1 = Team()
t1.setTeam("Man-Utd", 1)
t1.displayTeam()
 from oop.py are getting executed ?  
Is initialization not allowed in modules ? What should I do if I only want class Team structure and not other stuff of module ? Corerct me if I am wrong somewhere.
 
     
     
    