Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49551

Re: File exists but Python says 'not found'.

Date 2013-07-01 07:38 -0400
From Dave Angel <davea@davea.name>
Subject Re: File exists but Python says 'not found'.
References <5c1d1e47-b67e-4bce-8601-b14c0215f450@googlegroups.com> <mailman.4063.1372676395.3114.python-list@python.org> <fc85cde6-7308-4858-8f89-c218a980e427@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.4065.1372678710.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 07/01/2013 07:00 AM, prerit86@gmail.com wrote:
> I got it. The working directory was different. Sorry, I'm new and didn't the working directory has to be the location of the data. I thought the location of .py file and data file should be same. Thanks! Es. Robert Kern.
>

Python didn't make that assumption, the author of the script did.  By 
using a relative name like train.csv, he is implicitly forcing Python to 
use the current working directory.

If he had wanted the file to be found in the same directory as one of 
the source files, he could have built an absolute path by using the 
__file__ attribute of the module.

However, for non-const files, the source directory is generally a bad 
place to put them.

Confounding things is the strange habit that Windows has of deciding 
that the script location *should* be your current directory.  I believe 
Explorer does that if you right-click select a script.


-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

File exists but Python says 'not found'. prerit86@gmail.com - 2013-07-01 03:47 -0700
  Re: File exists but Python says 'not found'. Robert Kern <robert.kern@gmail.com> - 2013-07-01 11:56 +0100
  Re: File exists but Python says 'not found'. prerit86@gmail.com - 2013-07-01 03:57 -0700
    Re: File exists but Python says 'not found'. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-07-01 13:15 +0200
      Re: File exists but Python says 'not found'. prerit86@gmail.com - 2013-07-01 04:32 -0700
  Re: File exists but Python says 'not found'. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-07-01 12:59 +0200
    Re: File exists but Python says 'not found'. prerit86@gmail.com - 2013-07-01 04:00 -0700
      Re: File exists but Python says 'not found'. Dave Angel <davea@davea.name> - 2013-07-01 07:38 -0400
        Re: File exists but Python says 'not found'. prerit86@gmail.com - 2013-07-01 05:17 -0700

csiph-web