os,access argument problem
Thomas Wouters
thomas at xs4all.net
Mon Aug 21 04:02:45 EDT 2000
On Sun, Aug 20, 2000 at 05:05:52PM -0700, Bob van der Poel wrote:
> > os.access("foo",os.F_OK)
> Ahh... actually, I'd tried os.access("foo", F_OK) and using a string was
> an act of desperation. Never occurred that I'd have to use os.F_OK. I'm
> wondering if it makes more sense to 'from os import *', or should I
> learn to do it this way?
Learn to do it this way, *or* if you can't bear to type those three extra
characters, import the symbols you need explicitly, like so:
from os import F_OK
Do not import * from os! It will bite you in a big way: os defines a
function 'open', which is what most programming languages call 'fdopen': a
low level open that returns a filedescriptor. If you use 'from os import
*', you'll mask the normal, builtin open with os.open, resulting in other
strange errors later on.
from-mod-import-*-is-evil--don't-use-it!-ly y'rs,
(At least until you fully understand what it does and how it works, after
which you won't *want* to use it<wink>)
--
Thomas Wouters <thomas at xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
More information about the Python-list
mailing list