[Python-ideas] PEP 428 - object-oriented filesystem paths

Antoine Pitrou solipsis at pitrou.net
Sat Oct 6 22:39:34 CEST 2012


On Sat, 06 Oct 2012 13:19:54 -0700
Ethan Furman <ethan at stoneleaf.us> wrote:
> 
> If I understand Antoine's Path, the code would look something like:
> 
> job = '12345'
> home = Path('c:/orders/')[job]
> work = Path('c:/work/')
> for child in work:
>      if child.ext != '.pdf':
>          continue

You could actually write `for child in work.glob('*.pdf')`
(non-recursive) or `for child in work.glob('**/*.pdf')` (recursive).

Regards

Antoine.


-- 
Software development and contracting: http://pro.pitrou.net





More information about the Python-ideas mailing list