Ive just tried it this way but I get the error message at the bottom of the page when I run the returnFileList.py Module.
Traceback (most recent call last):
File "G:\2 Employment and Education\2 Education\2 Projects(All)\6 My Python Projects\MyPyProject\FileManagerProgram\1 Successfuly Tested\3 Working on - need to steeamline(22 09 19 9pm)\For Qs on Python Forum\returnFileList.py", line 7, in <module>
import listCWD
File "G:\2 Employment and Education\2 Education\2 Projects(All)\6 My Python Projects\MyPyProject\FileManagerProgram\1 Successfuly Tested\3 Working on - need to steeamline(22 09 19 9pm)\For Qs on Python Forum\listCWD.py", line 43, in <module>
listCWD()
NameError: name 'listCWD' is not defined
This is the code from theReturnFileList Module that gave the error message.
import os import globalVariables as gv if __name__ == '__main__': def listCWD(): """ This section lists everything in the current working directory the if condition means that the code beneath it will only run if this file(__name__) is the Main Module(__main__) e.g it will not run if this module has been imported into another module. """ try: gv.directoryList = os.listdir(gv.directoryIn) print('directoryList =\n',gv.directoryList) except FileNotFoundError: print('FileNotFoundError:\na List for the Directory gv.directoryIn cannnot be created\nbecause the Global Variable gv.directoryIn is an empty string.\n' 'To correct this either:\na)run the returnCWD function in this Module to assign a directory to gv.directoryIn or\nb)open the globalVariables.py file and setgv.directoryIn to = None') except TypeError: print('TypeError:\na List for the Directory gv.directoryIn cannnot be created\nbecause the Global Variable gv.directoryIn has been assigned to equal either:\n' 'a)List\nb)Set\nc)Tuple\n' 'To correct this either:\na)run the returnCWD function in this M odule to assign a directory to gv.directoryIn or\nb)open the globalVariables.py file and setgv.directoryIn to = None') except NameError: print('NameError:\nbecause of the Syntax Error on import a NameError now occurs in the functions code\n' 'To correct the SyntaxError above open the globalVariables.py file and do either of the solutions below\n' 'a)make directoryIn = an empty string\nb)make directoryIn = None') listCWD()Error Message:
Traceback (most recent call last):
File "G:\2 Employment and Education\2 Education\2 Projects(All)\6 My Python Projects\MyPyProject\FileManagerProgram\1 Successfuly Tested\3 Working on - need to steeamline(22 09 19 9pm)\For Qs on Python Forum\returnFileList.py", line 7, in <module>
import listCWD
File "G:\2 Employment and Education\2 Education\2 Projects(All)\6 My Python Projects\MyPyProject\FileManagerProgram\1 Successfuly Tested\3 Working on - need to steeamline(22 09 19 9pm)\For Qs on Python Forum\listCWD.py", line 43, in <module>
listCWD()
NameError: name 'listCWD' is not defined
This is the code from theReturnFileList Module that gave the error message.
import os print('The os module has been imported') import globalVariables as gv print('The globalVariables module has been imported') import returnCWD as cwd print('The returnCWD module has been imported') import listCWD print('The listCWD module has been imported') print() cwd.returnCWD() print('returnCWD ran corrrectly') print() # this function is running but not doing what i want # that is because of the if name = main condition in the functions code # i need to fix this whatever = listCWD.listCWD() print('listCWD ran corrrectly')