checking filespec for readability

Matthew Dixon Cowles matt at mondoinfo.com
Sun Aug 20 16:12:40 EDT 2000


On Sun, 20 Aug 2000 16:06:48 -0500, lynx <a at b.c> wrote:
>what's the simplest Python equivalent of Perl's -r operator?
>should i just stick to my workaround of open()ing it for reading
>and seeing if that throws anything?
>
>(more generally, what's the best replacement for each of Perl's
>filespec-checking operators? os.path methods and stat() magic?)

> - lynx, writing bomb-defuser code for cgi scripts

os.access is probably what you want. See:

http://www.python.org/doc/current/lib/os-file-dir.html

But if I were writing bomb-defuser code, I'd wrap the open()
in an exception handler too.

Regards,
Matt



More information about the Python-list mailing list