A little disappointed so far

Harry George hgg9140 at cola2.ca.boeing.com
Mon May 19 13:40:07 EDT 2003


Graham Nicholls <graham at rockcons.co.uk> writes:

> Aahz wrote:
> 
> > In article <PRVxa.118$573.48 at news-binary.blueyonder.co.uk>,
> > Graham Nicholls  <graham at rockcons.co.uk> wrote:
> >>
> >>Is there an equivalent of [ -f $filename ] to test for the existence of
> >>filename in Python?  Things like this seem essential for a shell tool
> >>language.
> > 


Every pythonista I know who was a serious Perl guy previously.  We all
wanted to start with "Can I write Perl idioms in Python?".  That
sounds about like what you are asking.  The answer is "Yes, but
eventually you will stop wanting to do so."

I for one really wanted those familiar Perl idioms, so I made a module
for them.  See "pyperlish" at:
http://www.seanet.com/~hgg9140/comp/index.html
http://www.seanet.com/~hgg9140/comp/pyperlish-1.2/doc/manual.html

Specifically, for your question see the file operations section:
   if p.f(myfile):
      #do something useful

(Notice that idioms regarding _, $_, and @_ are honored.)


-- 
harry.g.george at boeing.com
6-6M31 Knowledge Management
Phone: (425) 294-8757




More information about the Python-list mailing list