Re: How to get file descriptors of sys.stdin, sys.stdout and sys.stderr?

2014-11-13 Thread Ned Batchelder
On 11/13/14 7:54 PM, satishmlm...@gmail.com wrote: How to get file descriptors of sys.stdin, sys.stdout and sys.stderr? You don't seem to be reading any of the responses you are getting. At the very least, you don't seem to be understanding them, or engaging with the authors

How to get file descriptors of sys.stdin, sys.stdout and sys.stderr?

2014-11-13 Thread satishmlmlml
How to get file descriptors of sys.stdin, sys.stdout and sys.stderr? -- https://mail.python.org/mailman/listinfo/python-list

How to get file descriptors of sys.stdin, sys.stdout and sys.stderr?

2014-11-13 Thread satishmlmlml
How to get file descriptors of sys.stdin, sys.stdout and sys.stderr? -- https://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout and Python3

2013-11-24 Thread Chris Angelico
On Mon, Nov 25, 2013 at 1:31 AM, Steven D'Aprano wrote: > I don't think the REPL handles return values inside loops any different > from how it handles them outside loops. The difference is that file.write > methods used to return None in Python 2, in Python 3 they return the > number of bytes wri

Re: sys.stdout and Python3

2013-11-24 Thread Steven D'Aprano
s get printed. In > a script, that won't happen. To prevent that from happening > interactively, just assign the result to something: > > for i in range(10): > _=sys.stdout.write(".") > sys.stdout.flush() > > There definitely is a difference between Py2 a

Re: sys.stdout and Python3

2013-11-23 Thread Chris Angelico
assign the result to something: for i in range(10): _=sys.stdout.write(".") sys.stdout.flush() There definitely is a difference between Py2 and Py3 there, but it's nothing to do with sys.stdout - it's a change in the REPL (interactive interpreter, Read/Eval/Print Loop) and how it handles re

sys.stdout and Python3

2013-11-23 Thread Frank Millman
found that the new 'print' function has a 'flush' argument, so it can now be written as - for i in range(10): print('.', end='', flush=False) time.sleep(1) print() I tried to read the docs on sys.stdout, and I see a lot of changes in this area, but

Re: Buffering of sys.stdout and sys.stderr in python3 (and documentation)

2013-11-11 Thread swatkins
> sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0) which unfortunately doesn't work! I guess will resort to python3 -u, although I don't want stdout to be unbuffered. -- https://mail.python.org/mailman/listinfo/python-list

Re: Buffering of sys.stdout and sys.stderr in python3 (and documentation)

2013-11-11 Thread swatkins
It's surprising and broken that stderr should be buffered in python3. python3 calls setvbuf(3) on stderr at startup to achieve this chuckle-headed behavior. It makes stderr line buffered if on a terminal, and fully buffered if redirected to a log file. A fully buffered stderr is a very bad id

Re: python sys.stdout and C++ iostreams::cout

2013-01-17 Thread Lie Ryan
On 18/01/13 02:02, Utpal Sarkar wrote: Hi, I was assuming that sys.stdout would be referencing the same physical stream as iostreams::cout running in the same process, but this doesn't seem to be the case. The following code, which makes a call to a C++ function with a python wrapper c

Re: python sys.stdout and C++ iostreams::cout

2013-01-17 Thread Chris Angelico
he same thing. Good luck, have fun. It's a LOT messier than simply assigning to sys.stdout, unfortunately. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: python sys.stdout and C++ iostreams::cout

2013-01-17 Thread Utpal Sarkar
Thanks a lot Chris and Nobody! I'll have a look at dup2 for a start. > > I was assuming that sys.stdout would be referencing the same physical > > stream as iostreams::cout running in the same process, but this doesn't > > seem to be the case. > > > >

Re: python sys.stdout and C++ iostreams::cout

2013-01-17 Thread Chris Angelico
On Fri, Jan 18, 2013 at 2:02 AM, Utpal Sarkar wrote: > I was assuming that sys.stdout would be referencing the same physical stream > as iostreams::cout running in the same process, but this doesn't seem to be > the case. That's more-or-less true, but there will likely be

Re: python sys.stdout and C++ iostreams::cout

2013-01-17 Thread Nobody
On Thu, 17 Jan 2013 07:02:24 -0800, Utpal Sarkar wrote: > I was assuming that sys.stdout would be referencing the same physical > stream as iostreams::cout running in the same process, but this doesn't > seem to be the case. At startup, it refers to the same FILE* as C's std

python sys.stdout and C++ iostreams::cout

2013-01-17 Thread Utpal Sarkar
Hi, I was assuming that sys.stdout would be referencing the same physical stream as iostreams::cout running in the same process, but this doesn't seem to be the case. The following code, which makes a call to a C++ function with a python wrapper called "write", that writes

[SOLVED] Re: Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?

2012-10-24 Thread Daniel Dehennin
'datefmt' : '', }, 'stderr' : { 'format' : '%(message)s', 'datefmt' : '', }, },

Re: Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?

2012-10-23 Thread Daniel Dehennin
27;%(message)s', 'datefmt' : '', }, }, 'handlers' : { 'stdout' : { 'class' : 'logging.StreamHandler',

Re: [Python-ideas] changing sys.stdout encoding

2012-06-06 Thread Rurpy
in varying environments, the tools all have an --encoding option >>>>> to provide output that meets the needs and preferences of the >>>>> output's ultimate consumers. [snip] >>>>> In converting them to Python3, I found the best (if not very

Re: [Python-ideas] changing sys.stdout encoding

2012-06-06 Thread MRAB
iables, command line arguments, etc.) causes various issues. So I'm curious of your use cases. In converting them to Python3, I found the best (if not very pleasant) way to do this in Python3 was to put something like this near the top of each tool[*1]: import codecs sys.stdou

Re: what is best method to set sys.stdout to utf-8?

2012-03-07 Thread Laurent Claessens
tdout=sys.stdout def write(self,x): try: if isinstance(x,unicode): x=x.encode("utf8") except (UnicodeEncodeError,UnicodeDecodeError): sys.stderr.write("This should not happen !") raise self.old_stdout.wri

Re: what is best method to set sys.stdout to utf-8?

2012-03-07 Thread Terry Reedy
On 3/7/2012 3:57 PM, Peter Kleiweg wrote: In Python 3, there seem to be two ways to set sys.stdout to utf-8 after the script has started: sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach()) sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8

what is best method to set sys.stdout to utf-8?

2012-03-07 Thread Peter Kleiweg
In Python 3, there seem to be two ways to set sys.stdout to utf-8 after the script has started: sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach()) sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8') I guess the second is better. At start

Re: Buffering of sys.stdout and sys.stderr in python3 (and documentation)

2011-12-10 Thread Geoff Bache
Hi Terry, > The difference from 2.x should be in What's New in 3.0, except that the > new i/o module is in 2.6, so it was not exactly new. The io module existed in 2.6, but it was not used by default for standard output and standard error. The only mention of this in "What's New in 3.0" is in the

Re: Buffering of sys.stdout and sys.stderr in python3 (and documentation)

2011-12-09 Thread Terry Reedy
On 12/9/2011 2:32 PM, Geoff Bache wrote: Hi all, Short version: I'm a bit confused in general as to the changes between python2 and python3 regarding how standard output and standard error do buffering. A few things seem to have changed and I've failed to find any documentation of how and why.

Buffering of sys.stdout and sys.stderr in python3 (and documentation)

2011-12-09 Thread Geoff Bache
Hi all, Short version: I'm a bit confused in general as to the changes between python2 and python3 regarding how standard output and standard error do buffering. A few things seem to have changed and I've failed to find any documentation of how and why. Also, the meaning of "python -u" seems to h

Re: Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?

2011-09-02 Thread Vinay Sajip
On Aug 30, 9:53 am, Michel Albert wrote: > Unfortunately this setup makes `logging.basicConfig` pretty useless. > However, I believe that this is something that more people could > benefit from. I also believe, that it just "makes sense" to send > warnings (and above) to `stderr`, the rest to `s

Re: Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?

2011-08-30 Thread Michel Albert
ements. > > - I *always* create two stream handlers. One for `sys.stdout` with > > level `INFO` and one for `sys.stderr` with level `WARN` > > > Well, the levels may variate occasionally, but that's only the rare > > exception. > > How would a call to basicConf

Re: Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?

2011-08-30 Thread Peter Otten
Michel Albert wrote: > I use python oftentimes to write automation scripts on Linux servers. > And there's a big pattern in my scripts: > > - I *always* use `logging` instead of `print` statements. > - I *always* create two stream handlers. One for `sys.stdout` with > l

Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?

2011-08-30 Thread Michel Albert
Hi, I use python oftentimes to write automation scripts on Linux servers. And there's a big pattern in my scripts: - I *always* use `logging` instead of `print` statements. - I *always* create two stream handlers. One for `sys.stdout` with level `INFO` and one for `sys.stderr` with level

Re: sys.stdout vs. sys.stderr

2010-03-09 Thread Mitchell L Model
On Jan 11, 2010, at 1:47 PM Nobody wrote: On Mon, 11 Jan 2010 10:09:36 +0100, Martin v. Loewis wrote: In Python 3.1 is there any difference in the buffering behavior of the initial sys.stdout and sys.stderr streams? No. Were they different at some earlier point in Python's evol

Re: sys.stdout vs. sys.stderr

2010-01-11 Thread Nobody
On Mon, 11 Jan 2010 10:09:36 +0100, Martin v. Loewis wrote: >> In Python 3.1 is there any difference in the buffering behavior of the >> initial sys.stdout and sys.stderr streams? > > No. > >> Were they different at some earlier point in Python's evolution? &g

Re: sys.stdout vs. sys.stderr

2010-01-11 Thread Martin v. Loewis
> In Python 3.1 is there any difference in the buffering behavior of the > initial sys.stdout and sys.stderr streams? No. > Were they different at some earlier point in Python's evolution? That depends on the operating system. These used to be whatever the C library set up as std

sys.stdout vs. sys.stderr

2010-01-10 Thread Mitchell L Model
In Python 3.1 is there any difference in the buffering behavior of the initial sys.stdout and sys.stderr streams? They are both line_buffered and stdout doesn't seem to use a larger-grain buffering, so they seem to be identical with respect to buffering. Were they different at some ea

Re: sys.stdout is not flushed

2009-11-23 Thread Nobody
On Mon, 23 Nov 2009 23:08:25 +0100, Diez B. Roggisch wrote: > Try printing > >stdout.write('\r-->%d') ^M-->0^M-->1^M-->2^M-->3... ;) But it's probably good enough for the OP's purposes. -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 8:54 pm, Dave Angel wrote: > Jankins wrote: > > On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: > > >> Jankins schrieb: > > >>> I am trying to use sys.stdout to print out "process-bar" like: > >>> -->1% > > &g

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 8:32 pm, Cousin Stanley wrote: > >> > >> You misunderstand what "flush" means. It is not about > >> clearing the screen, or the line. > > >> Try printing > > >>    stdout.write('\r-->%d') > > >> Diez > > > But there is still a problem. When you use control character '\r', > > you a

Re: sys.stdout is not flushed

2009-11-23 Thread Dave Angel
Jankins wrote: On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: Jankins schrieb: I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): s

Re: sys.stdout is not flushed

2009-11-23 Thread Cousin Stanley
>> >> You misunderstand what "flush" means. It is not about >> clearing the screen, or the line. >> >> Try printing >> >>    stdout.write('\r-->%d') >> >> Diez > > > But there is still a problem. When you use control character '\r', > you actually move to the head of the current buffer line

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: > Jankins schrieb: > > > > > > > I am trying to use sys.stdout to print out "process-bar" like: > > -->1% > > > Here is my program ‘test.py’: > > > from sys import stdout > &g

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: > Jankins schrieb: > > > > > > > I am trying to use sys.stdout to print out "process-bar" like: > > -->1% > > > Here is my program ‘test.py’: > > > from sys import stdout > &g

Re: sys.stdout is not flushed

2009-11-23 Thread Diez B. Roggisch
Jankins schrieb: I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): stdout.write('-->%d' % v) stdout.flush() else: stdout.write('done!') #end for Then, I

sys.stdout is not flushed

2009-11-23 Thread Jankins
I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): stdout.write('-->%d' % v) stdout.flush() else: stdout.write('done!') #end for Then, I use 'python -

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-12 Thread Thierry
> Are you sure that Python wasn't just printing out "\n" because you'd > asked it to show you the repr() of a string containing newlines? Yes, I am sure. Because I dumped the ord() values to check them. But again, I'm stumped on how complicated I have made this. I should not try to code anymore at

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-12 Thread Steve Holden
Thierry wrote: > Thank you to both of you (Marc and Tino). > > I feel a bit stupid right now, because as both of you said, encoding > my source string to utf-8 do not produce an exception when I pass it > to urllib.quote() and is what it should be. > I was certain that this created an error sooner

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-12 Thread Thierry
Thank you to both of you (Marc and Tino). I feel a bit stupid right now, because as both of you said, encoding my source string to utf-8 do not produce an exception when I pass it to urllib.quote() and is what it should be. I was certain that this created an error sooner, and id not tried it again

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-12 Thread Marc 'BlackJack' Rintsch
On Tue, 11 Nov 2008 12:18:26 -0800, Thierry wrote: > I have realized an wxPython simple application, that takes the input of > a user, send it to a web service, and get back translations in several > languages. > The service itself is fully UTF-8. > > The "source" string is first encoded to "lati

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-11 Thread Tino Wildenhain
for help through google, I have found this post: http://mail.python.org/pipermail/python-list/2007-October/462977.html and I gave it a try. What I did, though, was not to override sys.stdout, but to declare a new writer stream as a property of my main class: self.out=OutStreamEncoder(sys.stdout,

sys.stdout, urllib and unicode... I don't understand.

2008-11-11 Thread Thierry
that unicode() would force python to consider the given text as unicode, not to try to convert it to unicode. Here again, trying several normalize/decode combination did not helped at all. Then, looking for help through google, I have found this post: http://mail.python.org/pipermail/python-list/2

Re: sys.stdout assign to- bug

2008-03-13 Thread castironpi
> import sys > class ThreadedOut: >         def __init__( self, old ): >                 self._old= old >         def write( self, s ): >                 self._old.write( s ) > sys.stdout= ThreadedOut( sys.stdout ) > > Python 3.0a2 WinXP, on the console.  'a&#x

sys.stdout assign to- bug

2008-03-12 Thread castironpi
d.write( s ) sys.stdout= ThreadedOut( sys.stdout ) >>> a >>> 0 0 Python 3.0a2 WinXP, on the console. 'a' is undeclared but error message isn't thrown. With 'sys.stdout= Thr...' commented: >>> a Traceback (most recent call last): File "&quo

Re: No tab completion if sys.stdout is redirected

2007-12-19 Thread Bjoern Schliessmann
Dirk Loss wrote: > Bjoern Schliessmann wrote: >> readline module applies its autocompletion functions to (and only >> to) sys.stdout. > > I see. Then I guess I'll have to avoid redirecting sys.stdout and > come up with some kind of workaround instead. Just use a &q

Re: No tab completion if sys.stdout is redirected

2007-12-19 Thread Dirk Loss
Bjoern Schliessmann wrote: > readline module applies its autocompletion functions to (and only > to) sys.stdout. I see. Then I guess I'll have to avoid redirecting sys.stdout and come up with some kind of workaround instead. Nevertheless, thanks for the info. Regards Di

Re: No tab completion if sys.stdout is redirected

2007-12-18 Thread Bjoern Schliessmann
Dirk Loss wrote: > I want to have tab completion in my program for interactive input. > Using readline and rlcompleter this works nicely. But I also have > to catch and modify all "print" output, so I redirect sys.stdout > to a custom file-like object. The problem is: A

No tab completion if sys.stdout is redirected

2007-12-18 Thread Dirk Loss
Hi, I want to have tab completion in my program for interactive input. Using readline and rlcompleter this works nicely. But I also have to catch and modify all "print" output, so I redirect sys.stdout to a custom file-like object. The problem is: After the redirection, readline sup

Interactive remote debugging by redirecting sys.stdin and sys.stdout to a socket or pipe

2007-07-25 Thread [EMAIL PROTECTED]
and sys.stdout to the socket # start interactive python e.g. ipython ipshellembed() # put sys.stdin and sys.stdout back to what they were # debugging session is done -- http://mail.python.org/mailman/listinfo/python-list

Problems redirecting STDOUT (NOT sys.stdout) to a pipe.

2006-03-19 Thread Elad
Hello All, I am trying to capture some printf's from a C function called by python. I have tried to following: STDOUT = 1# stdout fd (re, we) = os.pipe()# Create re / write handlers dup2(we, STDOUT)# override system's stdout, should dup first and restore later.. call_my_hello_world

Re: Getting the encoding of sys.stdout and sys.stdin, and changing it properly

2006-01-05 Thread velle
I have been studying your reply for many hours now, trying to figure it all out. I am novice in many respects; eg. I did not know neither Locale, the command locale, nl_langinfo(), hexdump, that ctrl+d is EOF, etc. :-) However I have found a way that solves my original problem, and I will post sol

Re: Getting the encoding of sys.stdout and sys.stdin, and changing it properly

2006-01-03 Thread Martin v. Löwis
en ... perhaps. This encoding will only be used when sending Unicode strings, not when sending byte strings (of those, Python cannot know what encoding they have, and it sends them unmodified). >>>>sys.stdout = codecs.getwriter('utf-8')(sys.stdout) >>>>sys.stdout.

Getting the encoding of sys.stdout and sys.stdin, and changing it properly

2006-01-03 Thread velle
' " simply write to sys.stdout? 2) Exactly what does the following line return? >>> sys.stdout.encoding 'ISO-8859-1' Is it the encoding of the terminal? I think not, because when I change the encoding in my terminal the result is still the same. Is it the encoding of t

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Jorgen Grahn a écrit : > On 9 Sep 2005 03:40:58 -0700, Sébastien Boisgérault <[EMAIL PROTECTED]> wrote: > > > > Fredrik Lundh wrote: > >> Sébastien Boisgérault wrote: > >> > >> > Thanks for your answer. The execution of your example leads to a > >> > 'aaa' display during 2 secs, before it is era

Re: sys.stdout

2005-09-09 Thread Jorgen Grahn
On 9 Sep 2005 03:40:58 -0700, Sébastien Boisgérault <[EMAIL PROTECTED]> wrote: > > Fredrik Lundh wrote: >> Sébastien Boisgérault wrote: >> >> > Thanks for your answer. The execution of your example leads to a >> > 'aaa' display during 2 secs, before it is erased by the prompt. >> > >> > This behav

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Fredrik Lundh a écrit : > > what "python shell" are you using, and what platform are you running > > it on? here's what I get on a standard Unix console: > > > import sys > sys.stdout.write("") > > >>> sys.stdout.write("\n") > > > sys.stdout.write("\n") >

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Fredrik Lundh wrote: > Sébastien Boisgérault wrote: > > > Thanks for your answer. The execution of your example leads to a > > 'aaa' display during 2 secs, before it is erased by the prompt. > > > > This behavior is standard ? The standard output is not supposed > > to *concatenate* the 'aaa' and

Re: sys.stdout

2005-09-09 Thread Fredrik Lundh
> what "python shell" are you using, and what platform are you running > it on? here's what I get on a standard Unix console: > import sys sys.stdout.write("") > >>> sys.stdout.write("\n") > sys.stdout.write("\n") > > >>> btw, what does >>> sy

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Robert Kern wrote: > Sébastien Boisgérault wrote: > > Tiissa, > > > > Thanks for your answer. The execution of your example leads to a > > 'aaa' display during 2 secs, before it is erased by the prompt. > > > > This behavior is standard ? The standard output is not supposed > > to *concatenate* t

Re: sys.stdout

2005-09-09 Thread Fredrik Lundh
Sébastien Boisgérault wrote: > Thanks for your answer. The execution of your example leads to a > 'aaa' display during 2 secs, before it is erased by the prompt. > > This behavior is standard ? The standard output is not supposed > to *concatenate* the 'aaa' and the '>>>' ? what "python shell" a

Re: sys.stdout

2005-09-09 Thread Robert Kern
Sébastien Boisgérault wrote: > Tiissa, > > Thanks for your answer. The execution of your example leads to a > 'aaa' display during 2 secs, before it is erased by the prompt. > > This behavior is standard ? The standard output is not supposed > to *concatenate* the 'aaa' and the '>>>' ? FWIW: P

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Tiissa, Thanks for your answer. The execution of your example leads to a 'aaa' display during 2 secs, before it is erased by the prompt. This behavior is standard ? The standard output is not supposed to *concatenate* the 'aaa' and the '>>>' ? SB -- http://mail.python.org/mailman/listinfo/pyt

Re: sys.stdout

2005-09-09 Thread tiissa
Sébastien Boisgérault a écrit : > The sys.stdout stream behaves strangely in my > Python2.4 shell: > > >>> import sys > >>> sys.stdout.write("") > >>> sys.stdout.write("\n") > > &

sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Hi, The sys.stdout stream behaves strangely in my Python2.4 shell: >>> import sys >>> sys.stdout.write("") >>> sys.stdout.write("\n") >>> sys.stdout.write("\n") >>> s

Re: redirecting messgaef from sys.stdout

2005-06-07 Thread harold fellermann
On 07.06.2005, at 16:43, Ahmad Hosseinzadeh wrote: > Hello, > > I’m trying to run an external program in my > application. Both are coded in python. I need to write > an independent module that is used in the main > application. Its responsibility is to run the external > program and redirect its

redirecting messgaef from sys.stdout

2005-06-07 Thread Ahmad Hosseinzadeh
Hello, I’m trying to run an external program in my application. Both are coded in python. I need to write an independent module that is used in the main application. Its responsibility is to run the external program and redirect its stdout and stderr to the main application. The application’s stdo

Re: sys.stdout question

2005-05-02 Thread Peter Otten
chris patton wrote: > I tried adding the comma at the end > print 'hello', > It still added that extra character. http://mail.python.org/pipermail/python-list/2003-September/184181.html Peter -- In diesen Kreisen kreiselt sich der Kreisler -- http://mail.python.org/mailman/listinfo/python-li

Re: sys.stdout question

2005-05-02 Thread M.E.Farmer
ring.','\n'] It would be hard to get to the next prompt after a print "dsfdfdssd", if the shell didn't add the \n to get it there. Also note most shells use repr or str behind the scenes for output to sys.stdout sys.stderr. >>> def g(): ... pass ... &g

Re: sys.stdout question

2005-05-02 Thread chris patton
I tried adding the comma at the end print 'hello', It still added that extra character. -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout question

2005-05-01 Thread M.E.Farmer
e syntax described above. This form is sometimes referred to as ``print chevron.'' In this form, the first expression after the >> must evaluate to a ``file-like'' object, specifically an object that has a write() method as described above. With this extended form, the su

Re: sys.stdout question

2005-05-01 Thread Steve Holden
chris patton wrote: >>>>import sys >>>>class stuff: > > ... things = [] > ... def write(self, string): > ... self.things.append(string) > ... > >>>>def_stdout = sys.stdout >>>>sys.stdout = stuff

sys.stdout question

2005-05-01 Thread chris patton
>>> import sys >>> class stuff: ... things = [] ... def write(self, string): ... self.things.append(string) ... >>> def_stdout = sys.stdout >>> sys.stdout = stuff() >>> print 'this is a string.' >>> print

sys.stdout / sys.stderr, subprocess, redirection

2005-04-04 Thread Roman Neuhauser
Hello, I have a piece of code that gets run in a script that has its stdout closed: import sys sys.stdout = sys.stderr c = subprocess.Popen (..., stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr