Q:

python function arguments

I have a Python function that inputs a string and should output a path along with doing some other operations within the function.
So the function looks like this, where testcase is the input and path should be returned:
def generate_testcase(testcase,path)
    path=os.path.join(os.getcwd(), testcase)
    return path

The function is a part of a package "regress" and is being called/used as: 
import regress
testcase='xyz'
regress.main.generate_testcase(testcase,path)
print path

Now I am getting an error that I have not defined path 
NameError: name 'path' is not defined

A:

The issue occurs because in your main script where you are calling - regress.main.generate_testcase(testcase,path) , you have not defined path yet. And that is exactly what the error tells you as well.
In Python, you do not need to pass in the argument that you need to return. You are not doing anything with the path variable passed in as argument, I am guessing you think its needed as path is returned from the function, but its not. Just remove it from the parameter list and then in the main script, make it so that path recieves the return value of the function. Example function -
def generate_testcase(testcase)
    path=os.path.join(os.getcwd(), testcase)
    return path

Example main script -
import regress
testcase='xyz'
path = regress.main.generate_testcase(testcase)
print path

