[PyAR2] Writing to a text file
pyar2 at cowsgomoo.org
Wed Jun 9 15:14:39 CEST 2010
redirecting stdout and piplines also works on windows/dos
c:\python25\python.exe script.py > results.txt
c:\python25\python.exe script.py | more
Since this is supposed to by a Pythonic place...you can do file i/o in your
f = open('results.txt', 'w') # note that this will overwrite any data in
f.write('a line full of stuff\n')
On Tue, Jun 8, 2010 at 23:41, Derek Horton <derek.k.horton at gmail.com> wrote:
> Since you are using linux there are a couple of things you can do. First,
> you could redirect the output (stdout) of your script to a file and then use
> an editor to view the file.
> python script.py > results.txt
> Now open the results.txt file in your favorite editor.
> Or you could pipe the output into less which will allow you to page through
> the output of your script by hitting the space bar.
> python script.py | less
> On Tue, Jun 8, 2010 at 10:09 PM, Daniel Veazey <daniel at danielveazey.com>wrote:
>> Hi, I'm totally new. I wrote a short program to find combinations on a
>> bike lock that have adjacent double digits. The lock has 4 digits, and each
>> digit can have a value of 1-6. So 1442 would have adjacent double digits,
>> and 1424 would not. Here is the program:
>> The problem I'm having is that when I run the program in a Linux terminal,
>> by the time all the combinations have been printed, the first half of the
>> combinations have run out of the top of the terminal's window.
>> So what I'd like to do is instead of just printing the numbers on the
>> screen, write them to a text file. Is there a way to do this? Does it have
>> something to do with stdout?
>> Daniel Veazey
>> danielveazey.com <http://www.danielveazey.com>
>> PyAR2 mailing list
>> PyAR2 at python.org
> PyAR2 mailing list
> PyAR2 at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyAR2