Re: Search for a file

From: Thomas Guettler (guettli_at_thomas-guettler.de)
Date: 06/10/04


Date: Thu, 10 Jun 2004 16:21:47 +0200

Am Thu, 10 Jun 2004 02:33:15 -0700 schrieb mithuna g:

> Hi All,
>
> I am new user of python. I would like to have your suggestions to do a task.
>
> Given a file name say a.c, is there any possiblity that will help in
> finding the location
> of the file.

Hi,

If you use unix try "locate". If locate
is not installed, try "find / -name 'a.c'"

If you want to do this in python, have
a look at os.listdir(). You need a recursive
function since you want to search in sub-directories,
too.

Or try os.path.walk()

Regards,
 Thomas



Relevant Pages

  • Re: sync dirs
    ... I've used that several times with great satisfaction, and it's fairly low-end - all you need is an FTP server at the other end. ... installer (or, at least, I have it somehow in my Windows Python 2.4, but ... not in my Cygwin Python 2.4. ...
    (comp.lang.python)
  • Re: Interpreter problem
    ... Of course you could just read and write the file in Python in text mode, that might get rid of the returns. ... There's probably a vim mode you can set to display the extraneous characters - it normally screams "^M" at me for files with carriage returns in them. ...
    (comp.lang.python)
  • Re: Success Natively Compiling Python-2.3.4 in Mingw?
    ... > Regards, Fernando ... Hello Fernando, ... check out the pyMinGW patch here: ... Python compiled under MinGW. ...
    (comp.lang.python)
  • Re: is this data structure build-in or Ill have to write my own class?
    ... assert dict.items==a ... structure of Python. ... - maintain the order (for iter and print) ...
    (comp.lang.python)
  • Re: goto
    ... > what is the equivalent of C languages' goto statement in python? ... > best regards ... And here is a Python equivalent using exception handling: ...
    (comp.lang.python)