Re: Python path and append

2016-04-29 Thread Steven D'Aprano
On Sat, 30 Apr 2016 06:26 am, boB Stepp wrote: > On Mon, Apr 25, 2016 at 8:51 PM, Steven D'Aprano > wrote: > >> See here for the *start* of a more professional approach: >> >> http://code.activestate.com/recipes/579097-safely-and-atomically-write-to-a-file/ > > What else would I need to know/co

Re: Python path and append

2016-04-29 Thread boB Stepp
On Mon, Apr 25, 2016 at 8:51 PM, Steven D'Aprano wrote: > See here for the *start* of a more professional approach: > > http://code.activestate.com/recipes/579097-safely-and-atomically-write-to-a-file/ What else would I need to know/consider in order to have a *complete* professional approach?

Re: Python path and append

2016-04-27 Thread Stephen Hansen
On Tue, Apr 26, 2016, at 07:56 PM, Seymore4Head wrote: > On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano > wrote: > > >On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote: > > > >> BTW I was trying to use a line like yours that used an output file > >> that didn't exist and was getting an error.

Re: Python path and append

2016-04-26 Thread Chris Angelico
On Wed, Apr 27, 2016 at 12:56 PM, Seymore4Head wrote: > On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano > wrote: > >>On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote: >> >>> BTW I was trying to use a line like yours that used an output file >>> that didn't exist and was getting an error. I a

Re: Python path and append

2016-04-26 Thread Seymore4Head
On Tue, 26 Apr 2016 19:16:56 +0100, Michael wrote: >If you want to read an entire file, append a space and asterisk and write it >to another file, this is the code you need: > >infile = open('win.txt', 'r') >text = f.read() >infile.close() >text += " *" >outfile = open('outfile.txt', 'w') >outfi

Re: Python path and append

2016-04-26 Thread Seymore4Head
On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano wrote: >On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote: > >> BTW I was trying to use a line like yours that used an output file >> that didn't exist and was getting an error.  I assume that import os >> fixes that. > > >Why would you assume th

Re: Python path and append

2016-04-26 Thread Michael
If you want to read an entire file, append a space and asterisk and write it to another file, this is the code you need: infile = open('win.txt', 'r') text = f.read() infile.close() text += " *" outfile = open('outfile.txt', 'w') outfile.write(text) outfile.close() If, on the other hand, you wis

Re: Python path and append

2016-04-25 Thread Gregory Ewing
Steven D'Aprano wrote: (Possible a few very old operating systems on supercomputers from the 1970s or 80s may have supported inserting... I seem to recall that VMS may have allowed that... but don't quote me.) I wouldn't be surprised if VMS provided some sort of indexed random-access file struc

Re: Python path and append

2016-04-25 Thread Dan Sommers
On Tue, 26 Apr 2016 11:51:23 +1000, Steven D'Aprano wrote: > ... (Possible a few very old operating systems on supercomputers from > the 1970s or 80s may have supported inserting... I seem to recall that > VMS may have allowed that... but don't quote me.) Some [non-supercomputer] OSes/filesystems

Re: Python path and append

2016-04-25 Thread Steven D'Aprano
On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote: > BTW I was trying to use a line like yours that used an output file > that didn't exist and was getting an error.  I assume that import os > fixes that. Why would you assume that? "Doctor, I have a problem with my arm, but I won't tell you wha

Re: Python path and append

2016-04-25 Thread Steven D'Aprano
On Tue, 26 Apr 2016 05:00 am, Seymore4Head wrote: > I was reading that. I have read it before. I don't use python enough > to even remember the simple stuff. Then when I try to use if for > something simple I forget how. It is perfectly fine to forget things that you read weeks or months befor

Re: Python path and append

2016-04-25 Thread Chris Angelico
On Tue, Apr 26, 2016 at 7:26 AM, John Gordon wrote: > It's much easier to create a new file and then rename it afterwards, > instead of rewriting the original file. And more importantly, it's safer. If anything happens to your process while it's doing its work, you'll have a junk file sitting aro

Re: Python path and append

2016-04-25 Thread Seymore4Head
On Mon, 25 Apr 2016 21:26:34 + (UTC), John Gordon wrote: >In <27nshbp40p1llr231dqm31p754tvurk...@4ax.com> Seymore4Head > writes: > >> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head >> wrote: > >> I am going to forget using a directory path. >> I would like to take the file win.txt and app

Re: Python path and append

2016-04-25 Thread Peter Otten
Random832 wrote: > On Mon, Apr 25, 2016, at 16:15, Seymore4Head wrote: >> Thanks for the tip. >> >> Still broke. :( >> >> f = open('wout.txt', 'r+') >> for line in f: >> if line=="": >> exit >> line=line[:-1] >> line=line+" *" >> f.write(line) >> print line >> f.clos

Re: Python path and append

2016-04-25 Thread John Gordon
In <27nshbp40p1llr231dqm31p754tvurk...@4ax.com> Seymore4Head writes: > On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head > wrote: > I am going to forget using a directory path. > I would like to take the file win.txt and append a space and the * > symbol. > f = open('win.txt', 'r+') > for line

Re: Python path and append

2016-04-25 Thread Seymore4Head
removing some other character. It's safer to use >line.rstrip("\n"). > >> -Original Message- >> From: Python-list >> [mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf >> Of Seymore4Head >> Sent: 25 April 2016 20:01

Re: Python path and append

2016-04-25 Thread Random832
On Mon, Apr 25, 2016, at 16:15, Seymore4Head wrote: > Thanks for the tip. > > Still broke. :( > > f = open('wout.txt', 'r+') > for line in f: > if line=="": > exit > line=line[:-1] > line=line+" *" > f.write(line) > print line > f.close() Your problem is that after y

Re: Python path and append

2016-04-25 Thread Seymore4Head
e beginning and the end of the string (default whitespace >characters). > >Use to remove return carriage--> line[:-1] > >-Original Message- >From: Python-list >[mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf Of >Seymore4Head >Sent: 25

Re: Python path and append

2016-04-25 Thread MRAB
ine ending, so line[:-1] could be removing some other character. It's safer to use line.rstrip("\n"). -Original Message- From: Python-list [mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf Of Seymore4Head Sent: 25 April 2016 20:01 To: python-list@python

Re: Python path and append

2016-04-25 Thread Rob Gaddi
Seymore4Head wrote: > On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi > wrote: > >>Seymore4Head wrote: >> >>> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head >>> wrote: >>> >>> I am going to forget using a directory path. >>> I would like to take the file win.txt and append a space and the

RE: Python path and append

2016-04-25 Thread Joaquin Alzola
ist [mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf Of Seymore4Head Sent: 25 April 2016 20:01 To: python-list@python.org Subject: Re: Python path and append On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi wrote: >Seymore4Head wrote: > >> On Tue, 19 Apr 2016

Re: Python path and append

2016-04-25 Thread Seymore4Head
On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi wrote: >Seymore4Head wrote: > >> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head >> wrote: >> >> I am going to forget using a directory path. >> I would like to take the file win.txt and append a space and the * >> symbol. >> >> f = open('win.

Re: Python path and append

2016-04-25 Thread Rob Gaddi
Seymore4Head wrote: > On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head > wrote: > > I am going to forget using a directory path. > I would like to take the file win.txt and append a space and the * > symbol. > > f = open('win.txt', 'r+') > for line in f: > f.read(line) > f.write(line+" *"

Re: Python path and append

2016-04-25 Thread Seymore4Head
On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head wrote: I am going to forget using a directory path. I would like to take the file win.txt and append a space and the * symbol. f = open('win.txt', 'r+') for line in f: f.read(line) f.write(line+" *") This doesn't work. Would someone fix

Re: Python path and append

2016-04-19 Thread Matthew Barnett
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("

Re: Python path and append

2016-04-19 Thread Chris Angelico
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") > IOErro

Re: Python path

2016-03-09 Thread Steven D'Aprano
On Wed, 9 Mar 2016 06:29 pm, ast wrote: > Hello > > Python path may be read with: > import sys sys.path > > There is an environnement variable $PYTHONPATH (windows) > to set if you want to add some additionnal directories to the > path. > > But the default path seems not to be stored

Re: Python path on windows

2015-02-21 Thread Chris Angelico
On Sun, Feb 22, 2015 at 1:10 AM, Dave Angel wrote: > But you could always write your own py.exe, which interprets the shebang > differently. > > Or run python.exe yourself, which as far as I know, pays no attention to > shebang lines. Or, my preferred solution: Fix the shebangs :) It's usually no

Re: Python path on windows

2015-02-21 Thread Dave Angel
On 02/21/2015 06:05 AM, Gisle Vanem wrote: Dave Angel wrote: Finally, when py.exe starts, it reads that first (shebang) line, and decides which python interpreter to actually use. py.exe? Do you mean python.exe? Reread my post, or read Mark's reply to yours. The job of py.exe or pyw.exe i

Re: Python path on windows

2015-02-21 Thread Mark Lawrence
On 21/02/2015 11:05, Gisle Vanem wrote: Dave Angel wrote: Finally, when py.exe starts, it reads that first (shebang) line, and decides which python interpreter to actually use. py.exe? Do you mean python.exe? py.exe or pyw.exe come with the Python launcher on Windows and work out which ve

Re: Python path on windows

2015-02-21 Thread Gisle Vanem
Dave Angel wrote: Finally, when py.exe starts, it reads that first (shebang) line, and decides which python interpreter to actually use. py.exe? Do you mean python.exe? Is there a way to make python.exe ignore all Shebang lines in all scripts? I had many generated .py-files with: #!g:\Prog

Re: Python path on windows

2015-02-20 Thread Wolfgang Maier
On 20.02.2015 19:25, Ian Kelly wrote: On Fri, Feb 20, 2015 at 8:16 AM, loial wrote: On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote: On Feb 20, 2015 7:46 AM, "loial" wrote: On Linux we use #!/usr/bin/env python At the start of scripts to ensure that the python execut

Re: Python path on windows

2015-02-20 Thread Mark Lawrence
On 20/02/2015 15:16, loial wrote: On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote: On Feb 20, 2015 7:46 AM, "loial" wrote: On Linux we use #!/usr/bin/env python At the start of scripts to ensure that the python executable used is the one defined in the PATH variable,

Re: Python path on windows

2015-02-20 Thread Ian Kelly
On Fri, Feb 20, 2015 at 8:16 AM, loial wrote: > On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote: >> On Feb 20, 2015 7:46 AM, "loial" wrote: >> >> > >> >> > On Linux we use >> >> > #!/usr/bin/env python >> >> > >> >> > At the start of scripts to ensure that the python executable used is

Re: Python path on windows

2015-02-20 Thread loial
On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote: > On Feb 20, 2015 7:46 AM, "loial" wrote: > > > > > > On Linux we use > > > #!/usr/bin/env python > > > > > > At the start of scripts to ensure that the python executable used is the > > one defined in the PATH variable, rather than

Re: Python path on windows

2015-02-20 Thread Ian Kelly
On Feb 20, 2015 7:46 AM, "loial" wrote: > > On Linux we use > #!/usr/bin/env python > > At the start of scripts to ensure that the python executable used is the one defined in the PATH variable, rather than hardcoding a path to the python executable. > > What is the equivalent functionality in Win

Re: Python path on windows

2015-02-20 Thread Dave Angel
On 02/20/2015 09:43 AM, loial wrote: On Linux we use #!/usr/bin/env python At the start of scripts to ensure that the python executable used is the one defined in the PATH variable, rather than hardcoding a path to the python executable. What is the equivalent functionality in Windows? Dep

Re: Python Path registry Key

2011-02-18 Thread Sathish S
Hi, Thanks for replying. Yes sys.prefix works in the python shell window. But I have to find out python's path from another application running on windows. How can I access sys.prefix from that application. Thanks, Sathish On Sat, Feb 19, 2011 at 12:50 AM, Westley Martínez wrote: > On Fri, 201

Re: Python Path registry Key

2011-02-18 Thread Westley Martínez
On Fri, 2011-02-18 at 11:56 +0530, Sathish S wrote: > Hi Ppl, > > > I'm trying to launch IDLE from another application. For this I need > the python directory path. I have been trying to get the Active Python > versions path from the Windows registry. However, these registry > entries seem not be

Re: python path separator

2010-09-02 Thread Nobody
On Wed, 01 Sep 2010 23:57:21 -0700, swapnil wrote: > I could not find any documentation for variables os.path.sep and > os.path.altsep. Although the first is pretty straightforward can > anyone explain the purpose of the second variable? Is it even useful? The purpose is so that you can do e.g.:

Re: python path separator

2010-09-02 Thread swapnil
On Sep 2, 12:25 pm, Vlastimil Brom wrote: > 2010/9/2 swapnil :> I could not find any documentation > for variables os.path.sep and > > os.path.altsep. Although the first is pretty straightforward can > > anyone explain the purpose of the second variable? Is it even useful? > > According to issueh

Re: python path separator

2010-09-02 Thread Vlastimil Brom
2010/9/2 swapnil : > I could not find any documentation for variables os.path.sep and > os.path.altsep. Although the first is pretty straightforward can > anyone explain the purpose of the second variable? Is it even useful? > According to issue http://bugs.python.org/issue709428, os.path.altsep >

Re: Python Path Dictionary

2007-08-22 Thread bg_ie
On 21 Aug, 21:45, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On 8/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > > > On 21 Aug, 17:42, Gary Herron <[EMAIL PROTECTED]> wrote: > > > [EMAIL PROTECTED] wrote: > > > > Hi, > > > > > Do the Python Paths come in the form of a dictionary whe

Re: Python Path Dictionary

2007-08-21 Thread Chris Mellon
On 8/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On 21 Aug, 17:42, Gary Herron <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > > Hi, > > > > > Do the Python Paths come in the form of a dictionary where I can > > > access a particular path my its key in the registry? > > > > >

Re: Python Path Dictionary

2007-08-21 Thread aine_canby
On 21 Aug, 17:42, Gary Herron <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hi, > > > Do the Python Paths come in the form of a dictionary where I can > > access a particular path my its key in the registry? > > > For example, in PythonWin Tools>>Edit Python Paths shows the name as > >

Re: Python Path Dictionary

2007-08-21 Thread Gary Herron
[EMAIL PROTECTED] wrote: > Hi, > > Do the Python Paths come in the form of a dictionary where I can > access a particular path my its key in the registry? > > For example, in PythonWin Tools>>Edit Python Paths shows the name as > well of the address of each path > > Thanks, > > Aine > > If by "P

Re: Python Path

2006-07-27 Thread diffuser78
In my .basrc file I commented the line of ActivePyton and after reboot everything is fine now. I can use Python 2.4.3 even on console and SPE both. thanks [EMAIL PROTECTED] wrote: > I have two python 2.4s on my Ubuntu Linux box. One is Python 2.4.2 and > other is Python 2.4.3. I use SPE as an

Re: Python Path

2006-07-27 Thread John Salerno
[EMAIL PROTECTED] wrote: > I want to get rid of ActivePython which I happend to install because I > was trying to Test the IDE by ActiveState and I think this version of > Python was installed by it. > > I am happy using Python 2.4.3 but there is not way I am being able to > use it on console.

Re: Python Path Setting

2005-07-21 Thread Chris Curvey
http://www.python.org/doc/2.4.1/inst/search-path.html#SECTION00041 -- http://mail.python.org/mailman/listinfo/python-list