[Tutor] File mode tests

Steve lonetwin at gmail.com
Fri Jul 30 09:29:38 CEST 2004


Hi Bill,

On Thu, 29 Jul 2004 17:18:15 -0700, Bill Campbell <bill at celestial.net> wrote:
> I'm just getting my feet wet with python after programming primarily in
> perl since perl-3.something.

Welcome to the other side :)

>  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 :-).
> 
>         if ( -x path ) # is is executable
>         if ( -r path ) # is it readable
>         if ( -w path ) # is it writeable

The function os.access() povides these, have a look here:

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

> I would love to find documentation, something like ``python for the perl
> hacker'' that would help in the transition.

So would a lot many hackers who see the light :) ....here you go (urls
may wrap):

http://www.onlamp.com/pub/a/onlamp/2002/06/27/pythonandperl.html
http://www.minihttpserver.net/showasin/Cat_cbook_En_perl_to_python_migration-0201734885.htm

HTH
Steve

PS: forgive the cheeky-ness ....couldn't help myself :o)


More information about the Tutor mailing list