[Tutor] Removing files based upon time stamps

broek at cc.umanitoba.ca broek at cc.umanitoba.ca
Thu Jun 26 00:17:59 CEST 2008


----- Message from lie.1296 at gmail.com ---------
     Date: Thu, 26 Jun 2008 04:53:14 +0700
     From: Lie Ryan <lie.1296 at gmail.com>
Reply-To: lie.1296 at gmail.com
  Subject: [Tutor]  Removing files based upon time stamps
       To: tutor at python.org


> I'm not sure what caused your problem, but...
>
>> ?os.chdir("c:\BACKUPS\DEV1")
>
> This is a no-no. What if you have a path like this:
> 'C:\nice\try'
>
> what do you think would python be doing?
> It would parse \n as newline and \t as tab
>
> You should do this instead:
> r'?C:\nice\try'
> OR
> 'C:\\nice\\try'
>
> the first way is called raw string, the backslash lose its meaning
> the second way is by escaping the backslash.


Or, better still, 'C:/nice/try' --- windows accepts the fwd slash as a  
path separator.

Best,

Brian vdB


More information about the Tutor mailing list