[Tutor] File mode tests
Lloyd Kvam
pythonTutor at venix.com
Fri Jul 30 03:45:18 CEST 2004
On Thu, 2004-07-29 at 20:18, Bill Campbell wrote:
> I'm just getting my feet wet with python after programming primarily in
> perl since perl-3.something. I've read the Harms and McDonald ``The Quick
> Python Book'', and O'Reilly's ``Learning Python'', but haven't been able to
> find python equivalents to these perl tests (lots of others in os.path, but
> not these :-).
import os
>
> if ( -x path ) # is is executable
if os.access(path, os.X_OK):
> if ( -r path ) # is it readable
if os.access(path, os.R_OK):
>
> if ( -w path ) # is it writeable
if os.access(path, os.W_OK):
http://docs.python.org/lib/os-file-dir.html
This is the relevant piece of documentation for the os module. It is
more verbose than perl since Python offers these functions through a
module.
>
>
> I would love to find documentation, something like ``python for the perl
> hacker'' that would help in the transition.
Google may be able to help with that. Otherwise browse through the
Library reference:
http://docs.python.org/lib/lib.html
>
> Bill
> --
> INTERNET: bill at Celestial.COM Bill Campbell; Celestial Systems, Inc.
> UUCP: camco!bill PO Box 820; 6641 E. Mercer Way
> FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
> URL: http://www.celestial.com/
>
> ``Mechanical Engineers build weapons. Civil Engineers build targets.''
Interesting observation.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358
voice: 603-653-8139
fax: 801-459-9582
More information about the Tutor
mailing list