Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102148 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2016-01-27 10:19 +0100 |
| Last post | 2016-01-27 10:19 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Duplicate Output Peter Otten <__peter__@web.de> - 2016-01-27 10:19 +0100
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2016-01-27 10:19 +0100 |
| Subject | Re: Duplicate Output |
| Message-ID | <mailman.30.1453886415.2338.python-list@python.org> |
Peter Otten wrote:
> or use next():
>
> filenames = next(walk("."))[2]
> print(filenames)
Be warned though that if you try this with a non-existent or otherwise
inaccessible directory you will get an exception:
$ sudo mkdir forbidden
$ sudo chmod a-r forbidden
$ python3 -c 'import os; next(os.walk("forbidden"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
StopIteration
Back to top | Article view | comp.lang.python
csiph-web