Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102148
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Duplicate Output |
| Date | 2016-01-27 10:19 +0100 |
| Organization | None |
| Message-ID | <mailman.30.1453886415.2338.python-list@python.org> (permalink) |
| References | <56A7BF9A.1070709@verizon.net> <n8a1mm$v8o$1@ger.gmane.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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Duplicate Output Peter Otten <__peter__@web.de> - 2016-01-27 10:19 +0100
csiph-web