Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'referring': 0.07; 'python': 0.09; 'files:': 0.09; 'flush': 0.09; 'occasionally': 0.09; 'other,': 0.09; 'referencing': 0.09; 'script,': 0.09; 'separator.': 0.09; 'wrong,': 0.09; 'ignore': 0.13; 'properly': 0.15; '.py': 0.16; 'binaries': 0.16; 'exceptions;': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'line.split()': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'nearest': 0.16; 'subject:Discussion': 0.16; 'mon,': 0.16; 'string': 0.17; 'wrote:': 0.17; '>>>': 0.18; 'earlier': 0.21; 'fairly': 0.21; 'subject:Code': 0.22; 'help.': 0.22; "i'd": 0.22; 'example': 0.23; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '(which': 0.26; 'common': 0.26; 'am,': 0.27; 'correct': 0.28; 'all.': 0.28; 'chris': 0.28; 'run': 0.28; 'post': 0.28; 'received:192.168.1.3': 0.29; 'subject:some': 0.29; 'case,': 0.29; 'character': 0.29; 'convert': 0.29; 'words': 0.29; "i'm": 0.29; 'usually': 0.30; 'function': 0.30; 'file': 0.32; 'could': 0.32; 'says': 0.33; "he's": 0.33; 'problem': 0.33; 'to:addr :python-list': 0.33; "can't": 0.34; 'done': 0.34; 'path': 0.35; 'said,': 0.35; 'skip:f 40': 0.35; 'pm,': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'closing': 0.36; 'method': 0.36; 'useful': 0.36; 'being': 0.37; 'previous': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'mean': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'called': 0.39; 'skip:" 10': 0.40; 'received:192.168': 0.40; 'your': 0.60; 'july': 0.60; 'close': 0.63; 'necessarily': 0.63; 'worth': 0.63; 'more': 0.63; 'jul': 0.65; 'talking': 0.66; 'header:Reply-To:1': 0.68; 'believe': 0.69; 'soon': 0.70; 'reply-to:no real name:2**0': 0.72; 'bag': 0.75; "'with'": 0.84; 'about,': 0.84; 'reply-to:addr:python.org': 0.84; 'habit': 0.91; 'rick': 0.91; 'try.': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=coAZYiEi c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=YsUzL_8ObRgA:10 a=k-sDCyaxkTcA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=pGLkceISAAAA:8 a=2hMXqh2CCCuGYRyT8yMA:9 a=wPNLvfGTeEIA:10 a=MSl-tDqOz04A:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Sun, 08 Jul 2012 19:27:24 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Discussion on some Code Issues References: <3c4e2ef9-bf7e-4fbc-bf12-6780fdc3e5d4@googlegroups.com> <09adb3cf-f3f2-4acc-b561-a36dcf15ecc7@googlegroups.com> <11832de7-a064-494e-b3e8-32a2f15a6902@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341772228 news.xs4all.nl 6911 [2001:888:2000:d::a6]:47876 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25049 On 08/07/2012 18:17, Chris Angelico wrote: > On Mon, Jul 9, 2012 at 3:05 AM, wrote: >> On Sunday, July 8, 2012 1:33:25 PM UTC+5:30, Chris Angelico wrote: >>> On Sun, Jul 8, 2012 at 3:42 PM, wrote: >>> > file_open=open("/python32/doc1.txt","r") >>> Also, as has already been mentioned: keeping your data files in the >>> Python binaries directory isn't usually a good idea. More common to >>> keep them in the same directory as your script, which would mean that >>> you don't need a path on it at all. >> No file path! Amazing. I do not know I like to know one small example please. > > open("doc1.txt","r") > > Python will look for a file called doc1.txt in the directory you run > the script from (which is often going to be the same directory as your > .py program). > >> Btw, some earlier post said, line.split() to convert line into bag of words can >> be done with power(), but I did not find it, if any one can help. I do close >> files do not worry. New style I'd try. > > I don't know what power() function you're talking about, and can't > find it in the previous posts; the nearest I can find is a post from > Ranting Rick which says a lot of guff that you can ignore. (Rick is a > professional troll. Occasionally he says something useful and > courteous; more often it's one or the other, or neither.) > I believe the relevant quote is """especially the Python gods have given you *power* over string objects""". If that's the case, he's not referring to a method or a function called "power". He did give the good warning about the problem there could be if the original string contains "$", the character being used as the separator. > As to the closing of files: There are a few narrow issues that make it > worth using the 'with' statement, such as exceptions; mostly, it's > just a good habit to get into. If you ignore it, your file will > *usually* be closed fairly soon after you stop referencing it, but > there's no guarantee. (Someone else will doubtless correct me if I'm > wrong, but I'm pretty sure Python guarantees to properly flush and > close on exit, but not necessarily before.) >