On Feb 4, 8:20 pm, exar...@twistedmatrix.com wrote:
On 01:56 am, jonny.lowe.12...@gmail.com wrote:
Hi everyone,
Is there an easy way to mergestdinandstdout? For instance suppose I
havescriptthat prompts for a number and prints the number. If you
execute this with redirection from a file
En Fri, 05 Feb 2010 17:39:07 -0300, jonny lowe
jonny.lowe.12...@gmail.com escribió:
On Feb 4, 8:20 pm, exar...@twistedmatrix.com wrote:
On 01:56 am, jonny.lowe.12...@gmail.com wrote:
What I want is to have an easy way to merge input.txt and thestdout
so that output.txt look like:
Enter a
Hi everyone,
Is there an easy way to merge stdin and stdout? For instance suppose I
have script that prompts for a number and prints the number. If you
execute this with redirection from a file say input.txt with 42 in the
file, then executing
./myscript input.txt output.txt
the output.txt
On 01:56 am, jonny.lowe.12...@gmail.com wrote:
Hi everyone,
Is there an easy way to merge stdin and stdout? For instance suppose I
have script that prompts for a number and prints the number. If you
execute this with redirection from a file say input.txt with 42 in the
file, then executing
Chris wrote:
On May 28, 11:08 am, [EMAIL PROTECTED] wrote:
Say I have a file, utf8_input, that contains a single character, é,
coded as UTF-8:
$ hexdump -C utf8_input
c3 a9
0002
[...]
weird thing is 'c3 a9' is é on my side... and copy/pasting the é
gives me 'e9' with the
On May 28, 11:08 am, [EMAIL PROTECTED] wrote:
Hi,
I have problems getting my Python code to work with UTF-8 encoding
when reading from stdin / writing to stdout.
Say I have a file, utf8_input, that contains a single character, é,
coded as UTF-8:
$ hexdump -C utf8_input
Shouldn't you do data = data.decode('utf8') ?
Yes, that's it! Thanks.
-- dave
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I have problems getting my Python code to work with UTF-8 encoding
when reading from stdin / writing to stdout.
Say I have a file, utf8_input, that contains a single character, é,
coded as UTF-8:
$ hexdump -C utf8_input
c3 a9
0002
If I read this file
[EMAIL PROTECTED] writes:
Hi,
I have problems getting my Python code to work with UTF-8 encoding
when reading from stdin / writing to stdout.
Say I have a file, utf8_input, that contains a single character, é,
coded as UTF-8:
$ hexdump -C utf8_input
c3 a9
$ cat utf8_from_stdin.py
import sys
data = sys.stdin.read()
print length of data =, len(data)
sys.stdin is a byte stream in Python 2, not a character stream.
To make it a character stream, do
sys.stdin = codecs.getreader(utf-8)(sys.stdin)
HTH,
Martin
--
Hello,
I checked under linux and it works :
text.txt :
first line of the text file
second line of the text file
test.py :
import sys
a = sys.stdin.readlines()
x = ''.join(a)
x = x.upper()
sys.stdout.write(x)
cat text.txt | python test.py
But I reinstalled Python 2.5 under Windows XP and it
reinstalled Python 2.5 under Windows XP and it doesn't work
anyway. Can you confirm that your script works with Win XP and Python 2.5 ?
How are you invoking the script under WinXP? If you're
using the standard file associations then stdin/stdout
won't work correctly. However, they produce a specific
On Jan 22, 8:42 pm, Bernard Desnoues [EMAIL PROTECTED]
wrote:
Hello,
I checked under linux and it works :
text.txt :
first line of the text file
second line of the text file
test.py :
import sys
a = sys.stdin.readlines()
x = ''.join(a)
x = x.upper()
sys.stdout.write(x)
cat text.txt
Well, that's at least weird. I did test my code with Python 2.5 on Win
XP, using the command prompt. But testing it with IDLE gives exactly the
same error Bernard has. So apparently STDIN can't be accessed with IDLE.
Rolf
John Machin wrote:
Excuse me, gentlemen, may I be your referee
Hi,
This is Windows bug that is described here:
http://support.microsoft.com/default.aspx?kbid=321788
This article also contains solution: you need to add registry value:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer
InheritConsoleHandles = 1 (REG_DWORD type)
Sorry, I meant:
Alternatively you can use following command
cat file | python script.py
instead of
cat file | script.py
On Jan 22, 1:54 pm, Konstantin Shaposhnikov [EMAIL PROTECTED]
wrote:
Hi,
This is Windows bug that is described
On 1/21/2008 9:02 AM, Bernard Desnoues wrote:
Hi,
I've got a problem with the use of Redmon (redirection port monitor). I
intend to develop a virtual printer so that I can modify data sent to
the printer.
FWIW: there is a nice update the RedMon (v1.7) called RedMon EE (v1.81)
available
On 1/22/2008 8:54 AM, Konstantin Shaposhnikov wrote:
Hi,
This is Windows bug that is described here:
http://support.microsoft.com/default.aspx?kbid=321788
This article also contains solution: you need to add registry value:
Hi,
I've got a problem with the use of Redmon (redirection port monitor). I
intend to develop a virtual printer so that I can modify data sent to
the printer.
Redmon send the data flow to the standard input and lauchs the Python
program which send modified data to the standard output (Windows
According to various tutorials this should work.
code
|import sys
data = sys.stdin.readlines()
print Counted, len(data), lines.|
/code
Please use google before asking such questions. This was found with only
one search for the terms 'python read stdin'
Rolf
Bernard Desnoues wrote:
Hi,
I've
Rolf van de Krol a écrit :
According to various tutorials this should work.
code
|import sys
data = sys.stdin.readlines()
print Counted, len(data), lines.|
/code
Please use google before asking such questions. This was found with only
one search for the terms 'python read stdin'
I don't know what you did with your Python installation, but for me this
works perfectly.
test3.py contains:
code
import sys
print sys.stdin.readlines()
/code
test.txt contains:
code
Testline1
Testline2
/code
Output of 'python test3.py test.txt' is:
code
['Testline1\n', 'Testline2']
/code
Guido van Rossum added the comment:
Committed revision 59984 (2.6).
Decided not to backport this to 2.5.
--
resolution: - fixed
status: open - closed
versions: -Python 2.5
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1786
Guido van Rossum added the comment:
Here's an improved patch -- the recursive debugger invocation should
pass the I/O settings on.
--
assignee: - gvanrossum
keywords: +easy
Added file: http://bugs.python.org/file9171/pdb.diff
__
Tracker [EMAIL
priority: low
severity: normal
status: open
title: pdb should set stdin+stdout around exec call
type: behavior
versions: Python 2.5, Python 2.6, Python 3.0
Added file: http://bugs.python.org/file9120/pdb.diff
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1786
Changes by Guido van Rossum:
--
keywords: +patch
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1786
__
___
Python-bugs-list mailing list
Unsubscribe:
replace3.py echo --- cat input.txt | python
replace3.py
from sys import stdin, stdout
def censor(foo, bar, input):
return input.replace(foo, bar)
fp = open('/dev/tty', 'r+')
fp.write('Remove what? ')
i = fp.readline().strip()
fp.write('Replace %s with what? ' %i)
o = fp.readline().strip
En Mon, 24 Sep 2007 04:04:07 -0300, per9000 [EMAIL PROTECTED] escribi�:
On 23 Sep, 18:24, Damjan [EMAIL PROTECTED] wrote:
I want to create a program that reads input from stdio that can prompt
a user for input while doing so without getting into problems.
...
The trick (which works on
certain words
***cat replace2.py
from sys import stdin, stdout
def censor(foo, bar, input):
return input.replace(foo, bar)
# i = raw_input('Remove what? ').strip()
# o = raw_input('Replace %s with what? ' %i).strip()
for line in stdin.xreadlines():
line = censor('foo', 'candy', line
I want to create a program that reads input from stdio that can prompt
a user for input while doing so without getting into problems.
...
As you can see I have commented out what I'd like to do but do not
know how to. Can I somehow halt the previous print to stdout (cat
input.txt) - if so can
BenjaMinster schrieb:
I want to read and write unicode on stdin and stdout. I can't seem to
find any way to force sys.stdin.encoding and sys.stdout.encoding to be
utf-8, so I've got the following workaround:
What operating system are you using? Why do you want to do this?
Python attempts to
I want to read and write unicode on stdin and stdout. I can't seem to
find any way to force sys.stdin.encoding and sys.stdout.encoding to be
utf-8, so I've got the following workaround:
import codecs, sys
out = codecs.getwriter(utf-8)(sys.stdout)
def tricky(): return
thank you very much for your help...
my big mistake,was to believe that | is the pipe symbol for both,unix and
python...
it is really annoying,how such a simple thing can mess things
Thank you for clearing this out.
_
Free blogging
asdsd sir wrote:
thank you very much for your help...
my big mistake,was to believe that | is the pipe symbol for both,unix and
python...
it is really annoying,how such a simple thing can mess things
Thank you for clearing this out.
It is indeed annoying when assumptions we carry from
Hi!I'm new in Python and i'd like to ask some general questions about
stdin,stdout...
Firstly...
if we type like something like :
cat file.txt|python somefile.py
#somefile.py
import sys
text=sys.stdin.read()
...then sys.stdin.read() will read from cats stdout...
However,if i type
Hello.
If you're new to Python, then input/output isn't the best place to
start. Begin with the tutorial:
http://docs.python.org/tut/tut.html
Other documentation is also linked to from there.
However, I will briefly answer your questions.
print hello|sys.stdin.read()
In Python the |
asdsd sir wrote:
Hi!I'm new in Python and i'd like to ask some general questions about
stdin,stdout...
Firstly...
if we type like something like :
cat file.txt|python somefile.py
#somefile.py
import sys
text=sys.stdin.read()
...then sys.stdin.read() will read from
Hello, I thought I'd write a program to collect information from pf
(packet filter) and insert it into a postgresql database for review on a
web page. First I checked if this has been done already, and found that
it has.. Using Perl and SQLite in a program called hatchet.
Well, I want to do it
On 2006-01-23, Jan Danielsson [EMAIL PROTECTED] wrote:
And if I'm reading it correctly, the Perl
script's process starts tcpdump, but redirects its output to its own
input, and reads it line by line.
[...]
...however, the Perl script solution looks interresting.. Is it
possible to do
On 2006-01-23, Grant Edwards [EMAIL PROTECTED] wrote:
On 2006-01-23, Jan Danielsson [EMAIL PROTECTED] wrote:
And if I'm reading it correctly, the Perl
script's process starts tcpdump, but redirects its output to its own
input, and reads it line by line.
[...]
...however, the Perl script
And if I'm reading it correctly, the Perl
script's process starts tcpdump, but redirects its output to its own
input, and reads it line by line.
And to clarify, what the Perl script is doing is redirecting the standard
error to standard out. STDIN is file handle 0, STDOUT is file handle 1,
and
In article [EMAIL PROTECTED],
Martijn Brouwer [EMAIL PROTECTED] wrote:
...
I read this one, which was the reason that I tried os.close instead of
sys.stdXXX.close(). But I would like to know why it does not close a
file discriptor is I call its close method().
They're special. I suppose
I am writing a unix daemon in python, so I want to close stdin, stdout
and stderr.
My first attempt was to the standard file descriptors using their
close() methods. After closing stdout, I could not print anymore, so
this seemed to work. However, later I noticed that they were not really
closed
Martijn Brouwer wrote:
I am writing a unix daemon in python, so I want to close stdin, stdout
and stderr.
My first attempt was to the standard file descriptors using their
close() methods. After closing stdout, I could not print anymore, so
this seemed to work. However, later I noticed
Robin Becker wrote:
Martijn Brouwer wrote:
I am writing a unix daemon in python, so I want to close stdin, stdout
and stderr.
My first attempt was to the standard file descriptors using their
close() methods. After closing stdout, I could not print anymore, so
this seemed to work. However
On Mon, 2005-12-26 at 23:13 +, Robin Becker wrote:
Martijn Brouwer wrote:
I am writing a unix daemon in python, so I want to close stdin, stdout
and stderr.
My first attempt was to the standard file descriptors using their
close() methods. After closing stdout, I could not print
On Mon, 2005-12-26 at 23:15 +, Robin Becker wrote:
Robin Becker wrote:
Martijn Brouwer wrote:
I am writing a unix daemon in python, so I want to close stdin, stdout
and stderr.
My first attempt was to the standard file descriptors using their
close() methods. After closing stdout
On Fri, 19 Aug 2005 15:26:27 GMT, max(01)* [EMAIL PROTECTED] wrote:
hi.
i was wondering, what's the simplest way to echo the standard input to
the standard output, with no modification.
i came up with:
...
but i guess there must be a simpler way.
using bash i simply do 'cat', *sigh*!
...
max(01)* wrote:
i was wondering, what's the simplest way to echo the standard input to
the standard output, with no modification.
...
ps: in perl you ca do this:
...
while ($line = STDIN)
{
print STDOUT ($line);
}
...
I guess you could, but there wouldn't be much point. In
hi.
i was wondering, what's the simplest way to echo the standard input to
the standard output, with no modification.
i came up with:
...
while True:
try:
raw_input()
except EOFError:
break
...
but i guess there must be a simpler way.
using bash i simply do 'cat', *sigh*!
2005/8/19, max(01)* [EMAIL PROTECTED]:
hi.
i was wondering, what's the simplest way to echo the standard input to
the standard output, with no modification.
i came up with:
...
while True:
try:
raw_input()
except EOFError:
break
...
but i guess there must be a
On Fri, 19 Aug 2005 15:26:27 GMT,
max(01)* [EMAIL PROTECTED] wrote:
ps: in perl you ca do this:
...
while ($line = STDIN)
{
print STDOUT ($line);
}
...
import fileinput
import sys
for line in fileinput.input():
sys.stdout.write(line)
Regards,
Dan
--
Dan Sommers
import sys
for l in sys.stdin:
sys.stdout.write(l)
-- George
--
http://mail.python.org/mailman/listinfo/python-list
max(01)* wrote:
i was wondering, what's the simplest way to echo the standard input to
the standard output, with no modification.
import sys
for line in iter(sys.stdin.readline, ''):
sys.stdout.write(line)
Note that this uses the second form of iter(), which calls its first
argument
gry@ll.mit.edu wrote:
import sys
for l in sys.stdin:
sys.stdout.write(l)
This is fine if you don't need the reads and writes of lines to run in
lockstep. File iterators read into a buffer, so you'll probably read
4096 bytes from stdin before you ever write a line to stdout. If
limodou wrote:
2005/8/19, max(01)* [EMAIL PROTECTED]:
hi.
i was wondering, what's the simplest way to echo the standard input to
the standard output, with no modification.
i came up with:
...
while True:
try:
raw_input()
except EOFError:
break
...
but i guess there must be a
On Sun, Jul 17, 2005 at 06:43:00PM -0700, chuck wrote:
I have found that sys.stdin.fileno() and sys.stdout.fileno() always
return -1 when executed from within a win32 service written using the
win32 extensions for Python.
Anyone have experience with this or know why?
because there *is* no
Interesting. The stdin and stdout objects in my service seems respond
to returing a string for the statements str(sys.stdin) and
str(sys.stdout). I guess they are just not attached to files?
Can you provide a reference (MSDN or otherwise) that indicates that
Windows Services don't have standard
It seems to simply be common wisdom. e.g.,
http://mail.python.org/pipermail/python-win32/2004-September/002332.html
http://mail.mems-exchange.org/pipermail/quixote-users/2004-March/002743.html
http://twistedmatrix.com/pipermail/twisted-python/2001-December/000644.html
etc
If you can find chapter
common wisdom interesting.
The value of the closed attribute is False when tested from within
the service.
Still digging
--
http://mail.python.org/mailman/listinfo/python-list
I have found that sys.stdin.fileno() and sys.stdout.fileno() always
return -1 when executed from within a win32 service written using the
win32 extensions for Python.
Anyone have experience with this or know why?
--
http://mail.python.org/mailman/listinfo/python-list
Michael McGarry [EMAIL PROTECTED] writes:
How do I redirect stdin, stdout and stderr to a window? I am using Qt
for GUI.
I don't know what specific mechanisms Qt provides, but the general
solution is to write a class that implements I/O methods like read,
readline, and write, and assign
Harry George [EMAIL PROTECTED] writes:
Normally the SOAP Servers are designed to take control of a port and
run their own sockets via inheritance from SocktServer.
But under inetd and xinetd, the port is controlled elsewhere and the
service just gets the stdin/stdout. I need to configure
101 - 163 of 163 matches
Mail list logo