redpath = os.path.realpath('.')
thispath = os.path.realpath(redpath)
fspec = glob.glob(redpath+'/*fits')
thispath = os.path.realpath(thispath+'/../../../..')
p = Path(thispath)
userinput = 'n'
while (userinput == 'n'):
text_file = next(p.glob('**/*.fits'))
print("Is this the correct file path?")
print(text_file)
userinput = input("y or n")
parent_dir = text_file.parent.resolve()
fspec = glob.glob(parent_dir+'/*fits')
I am getting the error
unsupported operand type(s) for +: 'WindowsPath' and 'str'
I think this is because I am trying to glob a Windows File Path when I need to glob a string. Is there a way that I can convert WindowsPath to string so that I can glob all the files into one list?
+
tryos.path.join()
. https://mcmap.net/q/49720/-how-should-i-write-a-windows-path-in-a-python-string-literal – Nearytype(parent_dir)
, I think it isWindowsPath
(not str). + operation failing due to different types. – FoliolatePath(...).resolve()
– Catholicon