Re: redirect standard output problem

2012-12-22 Thread Terry Reedy
On 12/22/2012 10:15 AM, Chris Angelico wrote: On Sun, Dec 23, 2012 at 2:07 AM, iMath wrote: when I run it through command line ,it works ok ,but when I run it through IDLE , only print A but leave out 888 so why ? Because IDLE has to fiddle with stdin/stdout a bit to function. Try adopting D

Re: redirect standard output problem

2012-12-22 Thread Chris Angelico
On Sun, Dec 23, 2012 at 2:07 AM, iMath wrote: > when I run it through command line ,it works ok ,but when I run it through > IDLE , only print A but leave out 888 > so why ? Because IDLE has to fiddle with stdin/stdout a bit to function. Try adopting Dave's recommendation - you'll likely find th

Re: redirect standard output problem

2012-12-22 Thread iMath
在 2012年12月21日星期五UTC+8下午3时24分10秒,Chris Angelico写道: > On Fri, Dec 21, 2012 at 4:23 PM, iMath wrote: > > > redirect standard output problem > > > > > > why the result only print A but leave out 888 ? > > > > No idea, because when I paste your code in

Re: redirect standard output problem

2012-12-21 Thread Dave Angel
On 12/21/2012 12:23 AM, iMath wrote: > redirect standard output problem > > why the result only print A but leave out 888 ? > > import sys > class RedirectStdoutTo: > > def __init__(self, out_new): > self.out_new = out_new > def __enter__(self): >

Re: redirect standard output problem

2012-12-21 Thread Hans Mulder
On 21/12/12 06:23:18, iMath wrote: > redirect standard output problem > > why the result only print A but leave out 888 ? > > import sys > class RedirectStdoutTo: > > def __init__(self, out_new): > self.out_new = out_new > def __enter__(self): >

Re: redirect standard output problem

2012-12-20 Thread Chris Angelico
On Fri, Dec 21, 2012 at 4:23 PM, iMath wrote: > redirect standard output problem > > why the result only print A but leave out 888 ? No idea, because when I paste your code into the Python 3.3 interpreter or save it to a file and run it, it does exactly what I would expect. A and 888 ge

redirect standard output problem

2012-12-20 Thread iMath
redirect standard output problem why the result only print A but leave out 888 ? import sys class RedirectStdoutTo: def __init__(self, out_new): self.out_new = out_new def __enter__(self): sys.stdout = self.out_new def __exit__(self, *args): sys.stdout = sys

output problem

2009-01-19 Thread Jean-Paul VALENTIN
true, Windows automatically adds a newline after the program output. But maybe there is a workaround? When you launch x.bat containing no char, windows adds a newline after the program output. But when you launch x.bat finishing with at least one CRLF, windows does not add a newline after the progr

Re: output problem

2009-01-18 Thread 7stud
On Jan 16, 8:24 am, "Jean-Paul VALENTIN" wrote: > Feature? the output of below Hello program he0.py started from command > line looks as follows: > F:\prompt>he0.py > Hello > F:\prompt> > > 'Hello' was sent with sys.stdout.write, so "without newline". > But why cannot be output (more logically): >

Re: output problem

2009-01-18 Thread Pierre Bourdon
IIRC, Windows automatically add a newline after the program output. On Fri, Jan 16, 2009 at 4:24 PM, Jean-Paul VALENTIN wrote: > Feature? the output of below Hello program he0.py started from command > line looks as follows: > F:\prompt>he0.py > Hello > F:\prompt> > > 'Hello' was sent with sys.st

output problem

2009-01-18 Thread Jean-Paul VALENTIN
Feature? the output of below Hello program he0.py started from command line looks as follows: F:\prompt>he0.py Hello F:\prompt> 'Hello' was sent with sys.stdout.write, so "without newline". But why cannot be output (more logically): F:\prompt>he0.py HelloF:\prompt> Is it normal? Is there any mean

Re: exception message output problem

2007-12-23 Thread Florian Diesch
Lie <[EMAIL PROTECTED]> wrote: > # Python have an odd (read: broken) singleton implementation > # single member tuple must have a comma behind it Otherwise (1+2)+(3+4) would evaluate to (3, 7) instead of 10. Florian --

Re: exception message output problem

2007-12-22 Thread Russ P.
On Dec 22, 5:34 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > Actually, the parens aren't needed, so this works too: > > > def __init__(self, args=""): self.args = args, > > > The trailing comma wasn't necessary a while back (pre 2.5?), so > > something in Python must have c

Re: exception message output problem

2007-12-22 Thread Lie
On Dec 23, 4:30 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Lie a écrit : > > > PPS: Actually, what makes a tuple is both the parens and the comma, > > Nope, it's definively the comma. You can check the language's grammar, > it's part of the doc. Or just test FWIW: > > Python 2.4.3 (#1, Ma

Re: exception message output problem

2007-12-22 Thread Bruno Desthuilliers
Lie a écrit : > On Dec 22, 6:18 am, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > >>Lie a écrit : >>(snip) >> >> >>># Python have an odd (read: broken) singleton implementation >>># single member tuple must have a comma behind it >> >>You may call it weird or even a wart if you want, but give

Re: exception message output problem

2007-12-22 Thread Bruno Desthuilliers
Lie a écrit : > PPS: Actually, what makes a tuple is both the parens and the comma, Nope, it's definively the comma. You can check the language's grammar, it's part of the doc. Or just test FWIW: Python 2.4.3 (#1, Mar 12 2007, 23:32:01) [GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pi

Re: exception message output problem

2007-12-22 Thread Mel
Lie wrote: > PPS: Actually, what makes a tuple is both the parens and the comma, > with comma as the minimum signifier, inspect this: "str(a) + > str((a,b,c))", you have to use the double parens, one to make the > tuple and the other as part of the str. This harmless little case > gives error if do

Re: exception message output problem

2007-12-22 Thread Fredrik Lundh
Russ P. wrote: > Actually, the parens aren't needed, so this works too: > > def __init__(self, args=""): self.args = args, > > The trailing comma wasn't necessary a while back (pre 2.5?), so > something in Python must have changed. I'd say that it looks a bit > cleaner without the trailing c

Re: exception message output problem

2007-12-22 Thread Lie
PPS: Actually, what makes a tuple is both the parens and the comma, with comma as the minimum signifier, inspect this: "str(a) + str((a,b,c))", you have to use the double parens, one to make the tuple and the other as part of the str. This harmless little case gives error if done without the double

Re: exception message output problem

2007-12-22 Thread Lie
On Dec 22, 6:18 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Lie a écrit : > (snip) > > > # Python have an odd (read: broken) singleton implementation > > # single member tuple must have a comma behind it > > You may call it weird or even a wart if you want, but given that what > makes the

Re: exception message output problem

2007-12-21 Thread Russ P.
On Dec 21, 2:58 pm, Lie <[EMAIL PROTECTED]> wrote: > Change the exception into this: > class InconsistentUnits(Exception): > def __init__(self, args=""): self.args = (args,) > # Python have an odd (read: broken) singleton implementation > # single member tuple must have a comma behind it

Re: exception message output problem

2007-12-21 Thread Bruno Desthuilliers
Lie a écrit : (snip) > # Python have an odd (read: broken) singleton implementation > # single member tuple must have a comma behind it You may call it weird or even a wart if you want, but given that what makes the tuple is the comma - not the parens[1] -, it is _not_ broken. [1] with the excep

Re: exception message output problem

2007-12-21 Thread Lie
On Dec 22, 2:57 am, "Russ P." <[EMAIL PROTECTED]> wrote: > I am baffled about why my exception messages are not displaying > properly. > > I have a class that represents physical scalars with units. If I type > > >>> 3 * s + 4 * m > > I should get something like this: > > scalar.InconsistentUnits:

exception message output problem

2007-12-21 Thread Russ P.
I am baffled about why my exception messages are not displaying properly. I have a class that represents physical scalars with units. If I type >>> 3 * s + 4 * m I should get something like this: scalar.InconsistentUnits: 3 s, 4 m to show that seconds cannot be added to meters. Instead, the m

Re: screen output problem

2006-11-29 Thread Ritesh Raj Sarraf
I'm not sure if there is a definite solution to this problem. I've noticed that one of the applications, which I use on a daily basis (apt from Debian) does address the progress bar issue in another way. When apt tries to download multiple files, it displays the progress of all the downloads on a

Re: screen output problem

2006-11-28 Thread Ritesh Raj Sarraf
On Sunday 26 November 2006 13:07, Calvin Spealman wrote: > Take a look at this: > http://cheeseshop.python.org/pypi/progressbar Hi, Sorry for being a little late in replying. The progressbar implementation is excellent but it has the same problems that the current progressbar implementation I u

Re: screen output problem

2006-11-25 Thread Calvin Spealman
On 25 Nov 2006 15:27:26 -0800, Ritesh Raj Sarraf <[EMAIL PROTECTED]> wrote: > Hi, > > I have, for very long, been trying to find a consistent solution (which > could work across major python platforms - Linux, Windows, Mac OS X) > for the following problem. > > I have a function which downloads fil

screen output problem

2006-11-25 Thread Ritesh Raj Sarraf
Hi, I have, for very long, been trying to find a consistent solution (which could work across major python platforms - Linux, Windows, Mac OS X) for the following problem. I have a function which downloads files from the web. I've made the function threaded. I'm trying to implement a progress bar