Dominique wrote:
Googling around this led me to try the following (to empty the bin):from win32com.shell import shell shell.SHEmptyRecycleBin() Unfortunately, this doesn't work. The traceback gives me : TypeError: SHEmptyRecycleBin() takes exactly 3 arguments (0 given) So, I tried something I found somewhere: from win32com.shell import shell shell.SHEmptyRecycleBin( #No confirmation dialog when emptying the recycle bin SHERB_NOCONFIRMATION = 0x00000001, #No progress tracking window during the emptying of the recycle bin SHERB_NOPROGRESSUI = 0x00000001), #No sound whent the emptying of the recycle bin is complete SHERB_NOSOUND = 0x00000004 ) This doesn't work either, giving me the following traceback: TypeError: SHEmptyRecycleBin() takes no keyword arguments Ooops! The 2 tracebacks are contradictory.
Well, not contradictory; more complementary. The help for shell.SHEmptyRecycleBin gives us 3 params: hwnd - parent window (or None) path - null-terminated root path or None for all recycle bins flags - some combination of SHERB constants Since it seems the args can't be keyword args (and since your example above seems to be more of a list of constants than a list of args), try this to empty the c-drive bin. Obviously you can play around with the constants by or-ing them together to give you that final arg: <code> from win32com.shell import shell, shellcon # flags = shellcon.SHERB_NOSOUND | shellcon.SHERB_NOCONFIRMATION flags = 0 shell.SHEmptyRecycleBin (None, "c:\\", flags) </code> You might want to look at my winshell module which wraps some of the shell module funcs in a slightly more Pythonic wrapper. At the very least, you can see some working source code: http://timgolden.me.uk/python/winshell.html TJG _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
