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
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?
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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
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+" *"
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
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("
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
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
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
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
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
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
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
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,
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
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
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
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
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
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
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.:
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
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
>
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
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?
> >
> > >
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
> >
[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
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
[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.
http://www.python.org/doc/2.4.1/inst/search-path.html#SECTION00041
--
http://mail.python.org/mailman/listinfo/python-list
49 matches
Mail list logo