[Tutor] list packing

John Fouhy john at fouhy.net
Mon Feb 27 05:14:54 CET 2006


On 27/02/06, kevin parks <kp8 at mac.com> wrote:
> snd = [f for f in os.listdir('/Users/kevin/snd/') if f.endswith('.aif')]

If this is all you need, then you could do something like:

snd = ['/Users/kevin/snd/%s' % f for f in
os.listdir('/Users/kevin/snd/') if f.endswith('.aif')]

Or, slightly more robustly (?),

snd = [os.path.join('/Users/kevin/snd', f) for f in
os.listdir('/Users/kevin/snd/') if f.endswith('.aif')]

--
John.


More information about the Tutor mailing list