[Tutor] Deleting specified files using a python program...help with code?
Kent Johnson
kent37 at tds.net
Sun Jun 29 21:33:12 CEST 2008
On Sun, Jun 29, 2008 at 11:13 AM, Saad Javed <sbjaved at gmail.com> wrote:
> import os
>
> list = ['*.ini', '*.db']
>
> for root, dirs, files in os.walk('/home/saad'):
> for list in files:
> os.remove(os.path.join('root', 'list'))
> print 'done'
>
> Unfortunately its a bit too efficient and nearly wiped my home dir before i
> manually killed it. Again...treat me like a super noob.
Hmmm...with the quotes on 'root' and 'list' it would only delete
/root/list. Please post the same code that you run!
Kent
More information about the Tutor
mailing list