DeaD_EyE thanks, I'll use this.
I didn't even know this had been built into python (since 3.4) until you mentioned it.
It's worth exploring what's there, here's a sample that just touches the surface
(I could have made this look exactly like Linux ls, but I'm too tired to do so now).
I didn't even know this had been built into python (since 3.4) until you mentioned it.
It's worth exploring what's there, here's a sample that just touches the surface
(I could have made this look exactly like Linux ls, but I'm too tired to do so now).
from pathlib import Path class SetPath: def __init__(self): self.make_paths() def make_paths(self): self.homepath = Path('.') self.show_contents(self.homepath) self.datapath = self.homepath / 'data' self.show_contents(self.datapath) self.zippath = self.homepath / '../ZipcodeData' self.show_contents(self.zippath) self.addrpath = self.zippath / 'ADDR' # print([f'{x}\n' for x in addrpath.iterdir()]) self.show_contents(self.addrpath) @staticmethod def show_contents(folder): print(f'\ndir {folder.name}') for item in folder.iterdir(): if item.is_dir(): print(f' d..{item}') else: print(f' ...{item}') if __name__ == '__main__': SetPath()gives:
Output:directory Name:
...CreateStateCdJsonFile.py
d..data
...FetchTiger2016AddrFiles.py
...MakeCensusNameJson.py
...SetPath.py
...snippet.py
...__init__.py
directory Name: data
...data\addrfiles.txt
...data\StateByName.json
directory Name: ZipcodeData
.....\ZipcodeData\4c90ea7b-1c0b-4ace-9eb0-a9eb01602f18.json
d....\ZipcodeData\ADDR
d....\ZipcodeData\ByState
.....\ZipcodeData\ea323919-fe1e-41e8-a53d-7404e0801116.json
.....\ZipcodeData\free-zipcode-database-Primary.csv
.....\ZipcodeData\free-zipcode-database.csv
.....\ZipcodeData\tlgdb_2017_a_us_addr.gdb.zip
d....\ZipcodeData\zcat
directory Name: ADDR
d....\ZipcodeData\ADDR\AK_02
d....\ZipcodeData\ADDR\AL_01
d....\ZipcodeData\ADDR\AR_05
d....\ZipcodeData\ADDR\AS_03
d....\ZipcodeData\ADDR\AS_60
d....\ZipcodeData\ADDR\AZ_04
d....\ZipcodeData\ADDR\CA_06
d....\ZipcodeData\ADDR\CO_08
d....\ZipcodeData\ADDR\CT_09
d....\ZipcodeData\ADDR\CZ_07
d....\ZipcodeData\ADDR\DC_11
d....\ZipcodeData\ADDR\DE_10
.....\ZipcodeData\ADDR\dirs.txt
d....\ZipcodeData\ADDR\FL_12
d....\ZipcodeData\ADDR\FM_64
d....\ZipcodeData\ADDR\GA_13
.....\ZipcodeData\ADDR\GetAllAddr.bat
.....\ZipcodeData\ADDR\makeDir.bat
.....\ZipcodeData\ADDR\tl_2016_01001_addr.zip
d....\ZipcodeData\ADDR\TN_47
d....\ZipcodeData\ADDR\TX_48
d....\ZipcodeData\ADDR\UM_74
d....\ZipcodeData\ADDR\UT_49
d....\ZipcodeData\ADDR\VA_51
d....\ZipcodeData\ADDR\VI_52
d....\ZipcodeData\ADDR\VI_78
d....\ZipcodeData\ADDR\VT_50
d....\ZipcodeData\ADDR\WA_53
d....\ZipcodeData\ADDR\WI_55
d....\ZipcodeData\ADDR\WV_54
d....\ZipcodeData\ADDR\WY_56