Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102148 > unrolled thread

Re: Duplicate Output

Started byPeter Otten <__peter__@web.de>
First post2016-01-27 10:19 +0100
Last post2016-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.


Contents

  Re: Duplicate Output Peter Otten <__peter__@web.de> - 2016-01-27 10:19 +0100

#102148 — Re: Duplicate Output

FromPeter Otten <__peter__@web.de>
Date2016-01-27 10:19 +0100
SubjectRe: 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web