Apr-11-2018, 01:01 AM
generally, executable files are kept in a bin directory
pictures would go in a directory named images.
This is a pseudo standard, which can be deviated from, but it is suggested naming.
look at pathlib: https://docs.python.org/3/library/pathlib.html
it maked file and directory navigation a snap.
for example, to create a refrence to your home directory, the code would be:
Now if you wanted to get a list of all files in bin:
pictures would go in a directory named images.
This is a pseudo standard, which can be deviated from, but it is suggested naming.
look at pathlib: https://docs.python.org/3/library/pathlib.html
it maked file and directory navigation a snap.
for example, to create a refrence to your home directory, the code would be:
from pathlib import Path home = Path('.')Next to create your bin directory under home you would use:
bin = home / 'bin' bin.mkdir(exist_ok=True)this will create the directory if not there, and only if not there.
Now if you wanted to get a list of all files in bin:
print([filename for filename in bin.iterdir() if filename.is_file()])