<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>I'm getting the "Digest" version of the mailing list, if there's any better way to respond to a specific message, I would like to know. thanks :><BR><BR><BR><BR>
<HR id=stopSpelling>
<BR>
> From: tutor-request@python.org<BR>> Subject: Tutor Digest, Vol 47, Issue 66<BR>> To: tutor@python.org<BR>> Date: Fri, 25 Jan 2008 02:09:13 +0100<BR>> <BR>> ------------------------------<BR>> <BR>> Message: 9<BR>> Date: Fri, 25 Jan 2008 01:11:00 -0000<BR>> From: "Alan Gauld" <alan.gauld@btinternet.com><BR>> Subject: Re: [Tutor] Dos and os.walk with Python<BR>> To: tutor@python.org<BR>> Message-ID: <fnbcrb$4ae$1@ger.gmane.org><BR>> Content-Type: text/plain; format=flowed; charset="iso-8859-1";<BR>> reply-type=original<BR>> <BR>> <BR>> "Timothy Sikes" <trs164@hotmail.com> wrote<BR>> <BR>> > I don't know if it's okay to ask about Dos in python mailing list,<BR>> <BR>> If its related to programming in python as well its fine :-)<BR>> <BR>> > I don't know if there are any formatting rules for posting programs<BR>> <BR>> It helps if we can see the formatting, especially since Python<BR>> relies on layout. This was just a mess on my screen!<BR>> <BR>> I've tried to sort it out...<BR>
<BR>
I can't seem to figure out how to make hotmail keep those spaces and new lines..... ah oh well<BR>
<BR>> <BR>> ---------------------------------------<BR>> import os, sys, time<BR>> <BR>> def earlierThan (path, year, exclude=[]):<BR>> all = []<BR>> walk = os.walk(path)<BR>> for root, dirs, files in walk:<BR>> for i in files:<BR>> try:<BR>> if (time.localtime(os.path.getmtime(root + "\\" + <BR>> i))[0] < year<BR>> and doesNotHave(exclude, root)) :<BR>> all.append(root + "\\" + i)<BR>> except OSError:<BR>> #I think that I might need a more specific error <BR>> message,<BR>> #as this one would handle something<BR>> #That's not necessarily a broken file name. (I got <BR>> one of them when I ran it).<BR>> print root + "\\" + i + " was not included in the <BR>> list"<BR>> return all<BR>> <BR>> def doesNotHave(exclude, root):<BR>> for x in exclude:<BR>> if root.startswith(x) > -1:<BR>> return False<BR>> return True<BR>> ----------------------------------------------<BR>> <BR>> That last function is a little odd. startswith already returns<BR>> a boolean so comparing to -1 is weird. I'm not sure what<BR>> you think it will do.<BR>
<BR>
yeah, I meant to have it as .find()<BR>
<BR>> <BR>> Consider:<BR>> <BR>> >>> 'fred'.startswith('x')<BR>> False<BR>> >>> 'fred'.startswith('x') > -1<BR>> True<BR>> >>> 'fred'.startswith('f') > -1<BR>> True<BR>> >>><BR>> <BR>> I'm not sure when it would ever fail the test so I think your<BR>> function will nearly always return False.<BR>> <BR>> > I've had little experience with dos. I believe I should use the<BR>> > COMPACT, and then the MOVE dos command... Would<BR>> > it go something like this?<BR>> <BR>> You could use these but you'd be better just using Python<BR>> to do it via the shutil and os modules and avoid the DOS<BR>> commands completely IMHO.<BR>> <BR>
<BR>
Okay, I've found the move command from the shutil module, but I don't see one that compressess files... Are there some? or am I just not seeing them...<BR>thanks.<BR><BR>> HTH,<BR>> <BR>> <BR>> -- <BR>> Alan Gauld<BR>> Author of the Learn to Program web site<BR>> http://www.freenetpages.co.uk/hp/alan.gauld <BR>> <BR>> <BR>> <BR>> <BR>> ------------------------------<BR>> <BR>> _______________________________________________<BR>> Tutor maillist - Tutor@python.org<BR>> http://mail.python.org/mailman/listinfo/tutor<BR>> <BR>> <BR>> End of Tutor Digest, Vol 47, Issue 66<BR>> *************************************<BR><BR><br /><hr />Helping your favorite cause is as easy as instant messaging. You IM, we give. <a href='http://im.live.com/Messenger/IM/Home/?source=text_hotmail_join' target='_new'>Learn more.</a></body>
</html>