test
and filenames
are only available inside your function. so you need to either call the function and assign the values to variable outside the function and then use them, or you could declare them as global in which case you don't need to return them.
So, you could either do this:
def read(textFile):
filenames = []
test = "test"
with open ("C:\\xampp\\htdocs\\test.new\\multiUploadTest\\var.txt", "r+") as myfile:
for line in myfile:
filenames.append(line)
print test
print (filenames)
return (filenames, test)
filenames, test = read(your_filename)
print filenames, test
or you could the following:
def read(textFile):
global filenames, test
filenames = []
test = "test"
with open ("C:\\xampp\\htdocs\\test.new\\multiUploadTest\\var.txt", "r+") as myfile:
for line in myfile:
filenames.append(line)
print test
print (filenames)
read(your_filename)
print filenames, test