how to run python script from shell
Question: I have a noob question.

I got a python script path1/path2/file.py

The script has a function:

    
    
    def run (datetime = None):
    

In the shell I call

    
    
    import path1.path2.file
    import datetime
    path1.path2.file.run(datetime = datetime(2011,12,1))
    

but I am getting TypeError: 'module' object is not callable

whats the correct way to call the method in the shell?


Answer: The problem is actually in the datetime module. You are trying to call the
module itself. The function you want to call is itself called datetime. so
what you want to call is:

    
    
    datetime.datetime()
    

OR you can import the function with:

    
    
    from datetime import datetime
    

and then call it with:

    
    
    datetime()
    

