Python 2.6.4 - method name is not defined
Question: Running a python script named `automator.py` from the command line using
powershell on windows 7.

`python .\automator.py`

`automator.py` file looks like this....

    
    
    import os
    
    ipAddressFile = os.path.join("DCM_Info", "ip_address")
    ipAddresses = getIpAddresses()
    
    for ip in ipAddresses:
        print str(ip)
        cmd = "python run.py " + ip  + " get_transrator_settings"
        os.system(cmd)
    
    
    def getIpAddresses():
        f = open(ipAddressFile, 'r')
        return f.readlines()
    

Why am I getting an error that the name of the method is undefined?

`NameError: name 'getIpAddresses' is not defined`

I'm used to C#/Java where you have a main method that starts the program and
classes that have constructors. Do I need to have a constructor or a class? Is
that necessary?


Answer: You need to move the function definition to be _before_ the first time it is
used. It can be easy to forget about this, since languages like JavaScript
allow functions to be declared after they're called.

