What do I import: file_name or class in Python?
Question: I have a file named **schedule.py** :

    
    
    class SchedGen:
        """ Class creates a pseudo random Schedule. 
        With 3/4 of total credit point required for graduation"""
        def __init__(self, nof_courses=40):
            random.seed()
            self.courses = {}
            self.nof_courses = nof_courses
    
            for i in xrange(nof_courses):
                self.courses[i] = college.Course(i)
    
            self.set_rand_cred()
            self.set_rand_chance()
            self.set_rand_preq_courses()
    
    
    
        def set_rand_cred(self):
            """ Set random credit to courses uniformly between 2 and 6"""
            temp_dict = self.courses.copy()
    

While importing content of schedule do I do `import schedule` like:

    
    
    import schedule
    

If that's correct how can I access the function set_rand_cred(self) from
SchedGen class?


Answer: You can either do

    
    
    import schedule
    schedgen = schedule.SchedGen()
    schedgen.set_rand_red()
    

or

    
    
    from schedule import SchedGen
    schedgen = SchedGen()
    schedgen.set_rand_red()
    

This link provides some information how Pythons [import
statement](http://effbot.org/zone/import-confusion.htm) works.

