Importing modules Python
Question: Hey I am having some trouble figuring out what is being asked to import in
this code

    
    
    #!/opt/local/bin/python
    
    import sys
    from formatter import Formatter
    
    def main():
    #do stuff
    

in my class formatter.py, do I have had to define a function with a name
Formatter. A little confused on this. I have been testing my code by putting

    
    
    from formatter import *
    

Which takes all the definitions in my class(I believe).


Answer: your line `from formatter import Formatter` will search through the module
formatter for anything with the name `Formatter`. so if you had a function
called `Formatter` in that module, it would be imported, meaning you could use
it in your main section (anywhere below the import line will work) It will
import classes as well.

`formatter.py` is a module. a class might look something like:

    
    
    class A:
        variable = 1
        def b():
            #do stuff
    

