fork download
  1. from pathlib import Path
  2.  
  3. def recursive_walk(path):
  4. yield path
  5.  
  6. if path.is_dir():
  7. for child in path.iterdir():
  8. yield from recursive_walk(child)
  9.  
  10. path = Path('/etc/systemd')
  11.  
  12. for item in recursive_walk(path):
  13. print(item)
  14.  
  15. print('--')
  16.  
  17. for item in path.glob('**/*'):
  18. print(item)
  19.  
Success #stdin #stdout 0.04s 28056KB
stdin
Standard input is empty
stdout
/etc/systemd
/etc/systemd/system
/etc/systemd/system/multi-user.target.wants
/etc/systemd/system/multi-user.target.wants/binfmt-support.service
/etc/systemd/system/timers.target.wants
/etc/systemd/system/timers.target.wants/apt-daily.timer
/etc/systemd/system/timers.target.wants/phpsessionclean.timer
--
/etc/systemd/system
/etc/systemd/system/multi-user.target.wants
/etc/systemd/system/timers.target.wants
/etc/systemd/system/multi-user.target.wants/binfmt-support.service
/etc/systemd/system/timers.target.wants/apt-daily.timer
/etc/systemd/system/timers.target.wants/phpsessionclean.timer