Testing for a file in python?
Moshe Zadka
moshez at math.huji.ac.il
Tue Jun 13 01:53:58 EDT 2000
On Tue, 13 Jun 2000, Thaddeus L. Olczyk wrote:
> >I don't know what you mean by "most".
> For all those who emailed me ( especially the nasty ones ) suggesting
> that I'm slamming Python in favor of Perl ( which I know well enough
> to know, I don't like it ) by most I mean:
>
> sh,csh,bash,tcsh,zsh ( and OK Perl )
IOW, sh and csh variants. And most of those *don't* have -f: it's the
test program (often symlinked to "[") that has that optin. Python can
run other executables to, so you could write
if os.system("[ -f %s ]" % filename)==0:
pass # file exists
So Perl is the only language that has it. I don't think awk has it,
and I'm certain neither guile nor Tcl have it. You have a really strange
definition of "most".
> Ones that I'm sure don't do it
> Python, sed ( and I'm not sure about sed, it's just not likely to be
> there ).
sed is hardly a scripting language (well, it's probably turing complete,
but it is quite hard to run other executables from it)
BTW:
You didn't mention Ruby (which I think does not have it), Rebol (ditto),
and others.
--
Moshe Zadka <moshez at math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com
More information about the Python-list
mailing list