On Apr 3, 2005 6:42 PM, Pierre Barbier de Reuille
<[EMAIL PROTECTED]> wrote:
> Tthe simplest, IMHO, is :
> 
> try:
>   f = file(filename, "w")
>   [...]
> except IOError:
>   print "The file is not writable"
> 
> Of course, not that this method empty the file if it is writable ! The
> best is to just put your IO code in such a try block ... That way,
> you're sure the file has the right mode.
> 
> If you don't want to open the file to detect its mode, then you need to
> use the os and stat modules together ...
> 
> Pierre
> 

I thought of this first. But I wasn't sure if it's the simplest.
Thanks for your help!
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to