Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P939
Command-Line Input
Active
Public
Actions
Authored by
zack
on Feb 4 2021, 12:00 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
zack@noziere:/tmp/t$ tree
.
├── a
├── b
├── c
├── d
│ ├── g
│ └── h
├── e
│ └── i
├── f
│ ├── j
│ ├── k
│ └── l
├── l -> f
├── walk_links.py
└── walk_nolinks.py
4 directories, 11 files
zack@noziere:/tmp/t$ cat walk_nolinks.py
#!/usr/bin/env python3
import os
for dirpath, dirnames, filenames in os.walk(".", followlinks=False):
for name in filenames:
print(os.path.join(dirpath, name))
zack@noziere:/tmp/t$ ./walk_nolinks.py
./walk_nolinks.py
./a
./walk_links.py
./c
./b
./f/l
./f/j
./f/k
./d/h
./d/g
./e/i
zack@noziere:/tmp/t$ cat walk_links.py
#!/usr/bin/env python3
import os
for dirpath, dirnames, filenames in os.walk(".", followlinks=True):
for name in filenames:
print(os.path.join(dirpath, name))
zack@noziere:/tmp/t$ ./walk_links.py
./walk_nolinks.py
./a
./walk_links.py
./c
./b
./l/l
./l/j
./l/k
./f/l
./f/j
./f/k
./d/h
./d/g
./e/i
zack@noziere:/tmp/t$
Event Timeline
zack
created this paste.
Feb 4 2021, 12:00 PM
2021-02-04 12:00:03 (UTC+1)
Log In to Comment