newbie q
Stephen Thorne
stephen.thorne at gmail.com
Thu Jan 13 01:47:05 EST 2005
On Thu, 13 Jan 2005 15:55:10 +1000, Egor Bolonev <ebolonev at mail.ru> wrote:
> how to get rid of 'for' operator in the code?
>
> import os, os.path
>
> def _test():
> src = 'C:\\Documents and Settings\\Егор\\My Documents\\My Music\\'
>
> for i in [x for x in os.listdir(src) if os.path.isfile(os.path.join(src,
> x)) and len(x.split('.')) > 1 and x.split('.')[-1].lower() == 'm3u']:
> os.remove(os.path.join(src, i))
>
> if __name__ == '__main__':
> _test()
import glob
for x in glob.glob("*.m3u"):
os.remove(x)
Regards,
Stephen Thorne
More information about the Python-list
mailing list