Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:not': 0.03; 'subject:Python': 0.06; 'attribute': 0.07; 'forcing': 0.09; 'python': 0.11; 'windows': 0.15; '*should*': 0.16; '.py': 0.16; 'did.': 0.16; 'right-click': 0.16; "subject:'.": 0.16; 'subject:File': 0.16; 'subject:exists': 0.16; 'wrote:': 0.18; 'select': 0.22; 'header:User-Agent:1': 0.23; 'directory.': 0.24; 'script.': 0.24; 'sorry,': 0.24; 'source': 0.25; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'generally': 0.29; 'absolute': 0.30; 'relative': 0.30; 'robert': 0.30; "i'm": 0.30; 'file': 0.32; 'thanks!': 0.32; 'could': 0.34; 'module.': 0.36; "didn't": 0.36; 'should': 0.36; 'same.': 0.38; 'to:addr:python- list': 0.38; 'does': 0.39; 'bad': 0.39; 'to:addr:python.org': 0.39; 'new': 0.61; 'email addr:gmail.com': 0.63; 'name': 0.63; 'believe': 0.68; 'received:74.208': 0.68; 'different.': 0.84; 'explorer': 0.84; 'received:74.208.4.194': 0.84; 'habit': 0.91; 'subject:found': 0.93 Date: Mon, 01 Jul 2013 07:38:12 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: File exists but Python says 'not found'. References: <5c1d1e47-b67e-4bce-8601-b14c0215f450@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:cC0ZE8y2QcY+wNUajzeftLggQ7ZC+2odjZtP1KJItIh D/SV9Vodx7xylxdDen2cWCdtdx1REepR8otZ0m5Z3xI0HX9COx Rk+KNf8nHeXDGQw0hqR4vN1Gu83F0ky9PenC6TqG8otOj9/DtX X/2yAjFYqbvxN2ezJlHkKMNfk1TzFyQvEoz1RMGOjA4vEBPhg0 8fIxmJnOJzoH0m2x0VSpuRWngfG2S38lqM7n0M8lOPjHrPYUKW aU2lubSyoMPWtaIYpWmSSwcbi8ZSVHwft1N9KMVGFE0MdyqsLK 1ecq+VcXX3B2qO93dVRGRGVhz9dKUXzEXUvffdZm4Co+bayrg= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372678710 news.xs4all.nl 15919 [2001:888:2000:d::a6]:45889 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49551 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