Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Matthew Barnett Newsgroups: comp.lang.python Subject: Re: Python path and append Date: Wed, 20 Apr 2016 00:36:52 +0100 Lines: 40 Message-ID: References: <5716C114.6000703@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de zr62ADHWi9d8k8mb4ukG9wkKPz8uxiQQWJ76HmoG6p5Q== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'append': 0.07; 'skip:\\ 10': 0.07; 'ioerror:': 0.09; 'literal': 0.09; 'wed,': 0.15; '2016': 0.16; 'backslashes': 0.16; 'expect,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'handle:': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'string': 0.17; '>>>': 0.20; 'prevent': 0.20; 'am,': 0.23; 'this:': 0.23; '(most': 0.24; 'plain': 0.24; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'chris': 0.26; 'skip:" 20': 0.26; 'error': 0.27; 'raw': 0.27; 'character': 0.29; 'print': 0.30; 'possibly': 0.32; 'traceback': 0.33; "skip:' 20": 0.34; 'file': 0.34; 'handle': 0.34; 'text': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'skip:p 20': 0.38; 'skip:o 20': 0.38; 'end': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'space': 0.40; 'some': 0.40; 'your': 0.60; 'you.': 0.64; '20,': 0.66; 'directory:': 0.84; 'drive.': 0.84; 'seymore4head': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=K//fZHiI c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=MZBWxn6V2mTkSrvCIzMA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett@:2500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-Reply-To: X-Mailman-Approved-At: Tue, 19 Apr 2016 20:07:39 -0400 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <5716C114.6000703@mrabarnett.plus.com> X-Mailman-Original-References: Xref: csiph.com comp.lang.python:107380 On 2016-04-19 23:38, Chris Angelico wrote: > On Wed, Apr 20, 2016 at 8:29 AM, Seymore4Head > wrote: >> >> handle = open("\\Winmx\New$\q.txt") >> for line in handle: >> line=line.strip() >> print line >> >> >> Traceback (most recent call last): >> File "\\Winmx\New$\add viewed.py", line 2, in >> handle = open("\\Winmx\New$\q.txt") >> IOError: [Errno 2] No such file or directory: '\\Winmx\\New$\\q.txt' >> >> What I would like to do is read a plain text file from a hidden >> network drive and append a space and the * character to the end of >> each line. > > Start with this: > > print("\\Winmx\New$\q.txt") > > If that doesn't do what you expect, it's possibly because you want to > use a raw string literal to prevent the backslashes from being parsed. > > handle = open(r"\\Winmx\New$\q.txt") > > That might help you. > > (One clue that this is happening is that some of your backslashes got > doubled in the error message.) > when printed out: >>> print "\\Winmx\New$\q.txt" \Winmx\New$\q.txt That's a file 2 directories down on the current drive.