Python (windows) will open files from command line, but not from a script launched from eclipse

Posted by Blake on Stack Overflow See other posts from Stack Overflow or by Blake
Published on 2010-04-10T19:59:45Z Indexed on 2010/04/10 20:03 UTC
Read the original article Hit count: 395

Filed under:
|
|

I'm pretty new to writing python for windows (linux is no problem), and am having problems getting python to recognize files when running scripts, though it behaves fine in the command line

What am I doing wrong here?

def verifyFile(x):
   #
   return os.path.isfile(x)

This will return true (with a valid file, of course) when called from the python command line, but when I run the script from eclipse, or launch it from windows, it ALWAYS returns false. Any thoughts on why this is?

I've tried passing pathnames like this: D:\Documents and Settings\BDE\Desktop\cdburn.jpg and like this: D:/Documents and Settings/BDE/Desktop/cdburn.jpg

I've changed sys,argv[0] to ''

I've tried this:

def verifyFile(x):
  #
  try:
      f = open(x, 'r')
      f.close()
      return True
  except:
      return False

and am getting no love!

Any help would be appreciated.

Thanks

Blake

© Stack Overflow or respective owner

Related posts about python

Related posts about files