wilfredinni / python-cheatsheet

All-inclusive Python cheatsheet
https://www.pythoncheatsheet.org
MIT License
4.25k stars 1.28k forks source link

Change strings to f-strings in Os module 'os.walk' example #336

Closed rjm001 closed 9 months ago

rjm001 commented 10 months ago

Small issue in module on Os. For the example in os.walk, they should be f strings. That is replace the existing:

>>> import os
>>>
>>> for folder_name, subfolders, filenames in os.walk('C:\\delicious'):
...     print(f'The current folder is {folder_name}')
...     for subfolder in subfolders:
...         print('SUBFOLDER OF {folder_name}: {subfolder}')
...     for filename in filenames:
...         print('FILE INSIDE {folder_name}: filename{filename}')
...     print('')

With

>>> import os
>>>
>>> for folder_name, subfolders, filenames in os.walk('C:\\delicious'):
...     print(f'The current folder is {folder_name}')
...     for subfolder in subfolders:
...         print(f'SUBFOLDER OF {folder_name}: {subfolder}')
...     for filename in filenames:
...         print(f'FILE INSIDE {folder_name}: filename{filename}')
...     print('')
LairdStreak commented 10 months ago

@ here WIP