(Sep-22-2019, 06:32 PM)ichabod801 Wrote: If the listCWD function definition is not in the if __name__ block, you should be able to run it like this:
import listCWD whatever = listCWD.listCWD()Remember, you want the definition outside the if __name__ block, and the actual call to it inside the if __name__ block.
If that does not solve your problem, please post some just enough runnable code to replicate the error, along with the full text of any error message.
Thanks for your reply. i tried what you said above but I got the error message below. i have added a url for all the files to my first post. im not an experienced coder and cant replicate the error with a smaller piece of code.
Traceback (most recent call last): File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\returnFileList.py", line 19, in <module> whatever = listCWD.listCWD() AttributeError: 'function' object has no attribute 'listCWD'
(Sep-22-2019, 06:32 PM)ichabod801 Wrote: If the listCWD function definition is not in the if __name__ block, you should be able to run it like this:
import listCWD whatever = listCWD.listCWD()Remember, you want the definition outside the if __name__ block, and the actual call to it inside the if __name__ block.
If that does not solve your problem, please post some just enough runnable code to replicate the error, along with the full text of any error message.
I forgot to alter the import statement last time so i tried what you recommended again and it has imported correctly and the function was called but it hasnt returned what i wanted. The output is below. The current working directory was returned but you will notice that the list of items in the directory did not print.
The os module has been imported The globalVariables module has been imported The returnCWD module has been imported The listCWD module has been imported The Current Working Directory is C:\Users\Me\AppData\Local\Programs\Python\Python37-32 returnCWD ran corrrectly listCWD ran corrrectly