I want to have the parameter for childDir
to be optional.
def saveFile(parentDir, *childDir, fileName):
# directory to store data
DIR_PATH = Path(__file__).parent/parentDir/childDir/fileName
# create dir_path if it does not exist
Path(DIR_PATH).mkdir(parents=True, exist_ok=True)
return DIR_PATH
saveFile("dirName", "dir", filename="test.py")
I'm getting an error
DIR_PATH = Path(file).parent/parentDir/childDir/fileName
TypeError: unsupported operand type(s) for /: 'WindowsPath' and 'tuple'