Re: [Tutor] Dos and os.walk with Python
Timothy Sikes wrote: > > 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 > :> > > I use Nabble ( http://www.nabble.com ). Great interface, multiple lists, tag messages, you can control list options, etc. all from one interface. I just set it to never send emails and read and reply from the Nabble page itself. Brian -- View this message in context: http://www.nabble.com/Dos-and-os.walk-with-Python-tp15078734p15097304.html Sent from the Python - tutor mailing list archive at Nabble.com. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dos and os.walk with Python
Timothy Sikes wrote: > I can't seem to figure out how to make hotmail keep those spaces and new > lines. ah oh well You are sending HTML mail. If you can configure hotmail to send plain text that is preferable. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dos and os.walk with Python
"Timothy Sikes" <[EMAIL PROTECTED]> wrote > 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 :> I used to use the digest before switching to the gmane news feed. I seem to recall there are two digest settings. One sends all the messages in one long message the other sends all the messages as attachments. The second method makes replying easier. I think its called Mime style? But its been a while... Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dos and os.walk with Python
>> I've had little experience with dos. I believe I should use the >> COMPACT, and then the MOVE dos command... Would >> it go something like this? > > You could use these but you'd be better just using Python > to do it via the shutil and os modules and avoid the DOS > commands completely IMHO. Python has the zipfile module which is very handy to use, which wasn't mentioned but provides the zip functionality that the OP was looking for. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dos and os.walk with Python
On Jan 24, 2008 5:28 PM, Timothy Sikes <[EMAIL PROTECTED]> wrote: > 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 :> > I also originally signed up for the digest - it drove me up the wall, so I subscribed to the regular feed instead. Lots more individual messages, but I have them filtered into a separate folder. Much, much easier to write replies this way. -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dos and os.walk with Python
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 :> > From: [EMAIL PROTECTED]> Subject: Tutor Digest, Vol 47, Issue 66> To: > tutor@python.org> Date: Fri, 25 Jan 2008 02:09:13 +0100> > > --> > Message: 9> Date: Fri, 25 Jan 2008 01:11:00 > -0000> From: "Alan Gauld" <[EMAIL PROTECTED]>> Subject: Re: [Tutor] Dos and > os.walk with Python> To: tutor@python.org> Message-ID: <[EMAIL PROTECTED]>> > Content-Type: text/plain; format=flowed; charset="iso-8859-1";> > reply-type=original> > > "Timothy Sikes" <[EMAIL PROTECTED]> wrote> > > I > don't know if it's okay to ask about Dos in python mailing list,> > If its > related to programming in python as well its fine :-)> > > I don't know if > there are any formatting rules for posting programs> > It helps if we can see > the formatting, especially since Python> relies on layout. This was just a > mess on my screen!> > I've tried to sort it out... I can't seem to figure out how to make hotmail keep those spaces and new lines. ah oh well > > ---> import os, sys, time> > def > > earlierThan (path, year, exclude=[]):> all = []> walk = os.walk(path)> for > > root, dirs, files in walk:> for i in files:> try:> if > > (time.localtime(os.path.getmtime(root + "\\" + > i))[0] < year> and > > doesNotHave(exclude, root)) :> all.append(root + "\\" + i)> except > > OSError:> #I think that I might need a more specific error > message,> #as > > this one would handle something> #That's not necessarily a broken file > > name. (I got > one of them when I ran it).> print root + "\\" + i + " was > > not included in the > list"> return all> > def doesNotHave(exclude, root):> > > for x in exclude:> if root.startswith(x) > -1:> return False> return True> > > --> > That last function is a > > little odd. startswith already returns> a boolean so comparing to -1 is > > weird. I'm not sure what> you think it will do. yeah, I meant to have it as .find() > > Consider:> > >>> 'fred'.startswith('x')> False> >>> 'fred'.startswith('x') > > > -1> True> >>> 'fred'.startswith('f') > -1> True> >>>> > I'm not sure when > > it would ever fail the test so I think your> function will nearly always > > return False.> > > I've had little experience with dos. I believe I should > > use the> > COMPACT, and then the MOVE dos command... Would> > it go > > something like this?> > You could use these but you'd be better just using > > Python> to do it via the shutil and os modules and avoid the DOS> commands > > completely IMHO.> 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...thanks.> HTH,> > > -- > Alan Gauld> Author of the Learn to Program web site> http://www.freenetpages.co.uk/hp/alan.gauld > > > > > --> > ___> Tutor maillist - Tutor@python.org> http://mail.python.org/mailman/listinfo/tutor> > > End of Tutor Digest, Vol 47, Issue 66> * _ Helping your favorite cause is as easy as instant messaging. You IM, we give. http://im.live.com/Messenger/IM/Home/?source=text_hotmail_join___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dos and os.walk with Python
"Timothy Sikes" <[EMAIL PROTECTED]> wrote > I don't know if it's okay to ask about Dos in python mailing list, If its related to programming in python as well its fine :-) > I don't know if there are any formatting rules for posting programs It helps if we can see the formatting, especially since Python relies on layout. This was just a mess on my screen! I've tried to sort it out... --- import os, sys, time def earlierThan (path, year, exclude=[]): all = [] walk = os.walk(path) for root, dirs, files in walk: for i in files: try: if (time.localtime(os.path.getmtime(root + "\\" + i))[0] < year and doesNotHave(exclude, root)) : all.append(root + "\\" + i) except OSError: #I think that I might need a more specific error message, #as this one would handle something #That's not necessarily a broken file name. (I got one of them when I ran it). print root + "\\" + i + " was not included in the list" return all def doesNotHave(exclude, root): for x in exclude: if root.startswith(x) > -1: return False return True -- That last function is a little odd. startswith already returns a boolean so comparing to -1 is weird. I'm not sure what you think it will do. Consider: >>> 'fred'.startswith('x') False >>> 'fred'.startswith('x') > -1 True >>> 'fred'.startswith('f') > -1 True >>> I'm not sure when it would ever fail the test so I think your function will nearly always return False. > I've had little experience with dos. I believe I should use the > COMPACT, and then the MOVE dos command... Would > it go something like this? You could use these but you'd be better just using Python to do it via the shutil and os modules and avoid the DOS commands completely IMHO. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor