Re: Is there a way to globally set the print function separator?

2017-10-10 Thread Steve D'Aprano
ion like the other solutions but is truly changing > the defaults for the existing function print? No. You are absolutely not changing the defaults for the actual built-in print function. There is no support for that in Python. What is happening is a bit more complex, but simplified: - func

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread John Black
In article , eryk...@gmail.com says... > > On Mon, Oct 9, 2017 at 10:04 PM, John Black wrote: > > In article , python@example.invalid says... > >> > >> Le 09/10/2017 à 18:22, John Black a écrit : > >> > I want sep="" to be the default without having to specify it every time I > >> > call print.

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread eryk sun
On Mon, Oct 9, 2017 at 10:04 PM, John Black wrote: > In article , python@example.invalid says... >> >> Le 09/10/2017 à 18:22, John Black a écrit : >> > I want sep="" to be the default without having to specify it every time I >> > call print. Is that possible? >> >> >>> oldprint = print >> >>>

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread Grant Edwards
On 2017-10-09, John Black wrote: > I want to make sure I understand what this line is doing: > >> oldprint = print > > Experimenting, I find this is not a rename because I can use both > function names. Right it's not _changing_ a name. It's _adding_ a name. > It looks it literally copies th

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread John Black
In article , python@example.invalid says... > > Le 09/10/2017 à 18:22, John Black a écrit : > > I want sep="" to be the default without having to specify it every time I > > call print. Is that possible? > > >>> oldprint = print > >>> def print(*args,**kwargs): > ... oldprint(*args,**kwargs,

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread Chris Angelico
On Tue, Oct 10, 2017 at 7:40 AM, John Black wrote: > In article , > __pete...@web.de says... >> >> John Black wrote: >> >> > I want sep="" to be the default without having to specify it every time I >> > call print. Is that possible? >> &

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread John Black
In article , __pete...@web.de says... > > John Black wrote: > > > I want sep="" to be the default without having to specify it every time I > > call print. Is that possible? > > No, but you can replace the print function with your own: > &g

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread Terry Reedy
On 10/9/2017 12:22 PM, John Black wrote: I want sep="" to be the default without having to specify it every time I call print. Is that possible? John Black Define a replacement print function that makes this the default. Something like (untested, a detail may be wrong): _print =

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread Peter Otten
John Black wrote: > I want sep="" to be the default without having to specify it every time I > call print. Is that possible? No, but you can replace the print function with your own: >>> print = functools.partial(print, sep="") >>> print("I

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread Python
Le 09/10/2017 à 18:22, John Black a écrit : I want sep="" to be the default without having to specify it every time I call print. Is that possible? >>> oldprint = print >>> def print(*args,**kwargs): ... oldprint(*args,**kwargs,sep='') ... >>> print(1,2,3) 123 -- https://mail.python.org/mail

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread Paul Moore
On 9 October 2017 at 17:22, John Black wrote: > I want sep="" to be the default without having to specify it every time I > call print. Is that possible? def myprint(*args, **kw): print(*args, sep="", **kw) If you want, assign print=myprint. Paul -- https://mail.python.org/mailman/listinf

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread Ned Batchelder
On 10/9/17 12:22 PM, John Black wrote: I want sep="" to be the default without having to specify it every time I call print. Is that possible? There isn't a way to change the default for print(sep="") globally. Generally when you want better control over the output, you use string formatti

Is there a way to globally set the print function separator?

2017-10-09 Thread John Black
I want sep="" to be the default without having to specify it every time I call print. Is that possible? John Black -- https://mail.python.org/mailman/listinfo/python-list

Re: Need help for the print() function with a better order

2016-10-03 Thread breamoreboy
On Sunday, October 2, 2016 at 2:12:39 AM UTC+1, 38016...@gmail.com wrote: > I am trying to print a simple decision tree for my homework. > The answer must keep in this format: > > Top 7,4,0.95 > career gain = 100 > 1.Management 2, 3, 0.9709505944546686 > 2.Service 5, 1, 0.6500224216483

Re: Need help for the print() function with a better order

2016-10-02 Thread 380162267qq
在 2016年10月2日星期日 UTC-4下午1:05:58,Peter Pearson写道: > On Sat, 1 Oct 2016 18:12:29 -0700 (PDT), 38016226...@gmail.com wrote: > > I am trying to print a simple decision tree for my homework. > > The answer must keep in this format: > > > > Top 7,4,0.95 > > career gain = 100 > > 1.Management 2, 3, 0.9

Re: Need help for the print() function with a better order

2016-10-02 Thread Peter Pearson
On Sat, 1 Oct 2016 18:12:29 -0700 (PDT), 38016226...@gmail.com wrote: > I am trying to print a simple decision tree for my homework. > The answer must keep in this format: > > Top 7,4,0.95 > career gain = 100 > 1.Management 2, 3, 0.9709505944546686 > 2.Service 5, 1, 0.6500224216483541 >

Need help for the print() function with a better order

2016-10-01 Thread 380162267qq
I am trying to print a simple decision tree for my homework. The answer must keep in this format: Top 7,4,0.95 career gain = 100 1.Management 2, 3, 0.9709505944546686 2.Service 5, 1, 0.6500224216483541 location gain = 100 1.Oregon 4, 1, 0.7219280948873623 2.Californ

Re: Print function not working

2016-08-11 Thread Michael Selik
On Thu, Aug 11, 2016 at 1:38 PM MRAB wrote: > On 2016-08-11 18:18, Chris Angelico wrote: > > On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra > > wrote: > >> I have installed IDLE 3.5.1 and wrote the following to check if print > is working. When it runs, I do not see anything is printed: > >> >

Re: Print function not working

2016-08-11 Thread MRAB
On 2016-08-11 18:18, Chris Angelico wrote: On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra wrote: I have installed IDLE 3.5.1 and wrote the following to check if print is working. When it runs, I do not see anything is printed: class Base: #{ def __init__( self ): #{ print("Hello

Re: Print function not working

2016-08-11 Thread Peter Otten
Atri Mahapatra wrote: > I have installed IDLE 3.5.1 and wrote the following to check if print is > working. When it runs, I do not see anything is printed: > > class Base: #{ > def __init__( self ): #{ > print("Hello, world: \n\n"); > > #} > > #} > > > if ( __name__ =

Re: Print function not working

2016-08-11 Thread Chris Angelico
On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra wrote: > I have installed IDLE 3.5.1 and wrote the following to check if print is > working. When it runs, I do not see anything is printed: > > class Base: #{ > def __init__( self ): #{ > print("Hello, world: \n\n"); > > #} > >

Print function not working

2016-08-11 Thread Atri Mahapatra
I have installed IDLE 3.5.1 and wrote the following print command to see if it is working. When I ran the code nothing is printed. Can you please point the reason- anything wrong with the code? class Base: #{ def __init__( self ): #{ print("Hello, world: \n\n"); #} #}

Print function not working

2016-08-11 Thread Atri Mahapatra
I have installed IDLE 3.5.1 and wrote the following to check if print is working. When it runs, I do not see anything is printed: class Base: #{ def __init__( self ): #{ print("Hello, world: \n\n"); #} #} if ( __name__ == " __main__"): #{ root = Base(); #} Can an

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Malcolm Greene
> You could use win_unicode_console enabled in sitecustomize or usercustomize. > https://pypi.python.org/pypi/win_unicode_console The pypi link you shared has an excellent summary of the issues associated when working Unicode from the Windows terminal. Thank you Eryk. Malcolm -- https://mail.py

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread eryk sun
On Wed, Aug 3, 2016 at 3:35 PM, Malcolm Greene wrote: > But under Windows, the stdout is workstation specific and *never* UTF-8. So > the > occasional non-ASCII string trips up our diagnostic output when tested under > Windows. You could use win_unicode_console enabled in sitecustomize or usercu

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Malcolm Greene
Chris, > Don't forget that the print function can simply be shadowed. I did forget! Another excellent option. Thank you! Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Chris Angelico
utput to the console with as few changes to the original scripts > as possible, eg. non-invasive except for the print statements > themselves. Don't forget that the print function can simply be shadowed. If you have a lot of code that uses print(...) to output text, and you want to qui

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Malcolm Greene
Thank you Random832 and Peter - excellent ideas. My use case was diagnostic output being (temporarily) output to stdout via debug related print statements. The output is for debugging only and not meant for production. I was looking for a solution that would allow me to output to the console with

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Random832
On Wed, Aug 3, 2016, at 11:09, Peter Otten wrote: > I'm unsure about this myself -- wouldn't it be better to detach the > underlying raw stream? Like Well, "better" depends on your point of view. > The ValueError raised if you try to write to the original stdout > looks like a feature to me. Ma

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Peter Otten
Random832 wrote: > On Wed, Aug 3, 2016, at 08:29, Malcolm Greene wrote: >> Looking for a way to use the Python 3 print() function with encoding and >> errors parameters. >> Are there any concerns with closing and re-opening sys.stdout so >> sys.stdout has a specific e

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Random832
On Wed, Aug 3, 2016, at 08:29, Malcolm Greene wrote: > Looking for a way to use the Python 3 print() function with encoding and > errors parameters. > > Are there any concerns with closing and re-opening sys.stdout so > sys.stdout has a specific encoding and errors behavior? W

print() function with encoding= and errors= parameters?

2016-08-03 Thread Malcolm Greene
Looking for a way to use the Python 3 print() function with encoding and errors parameters. Are there any concerns with closing and re-opening sys.stdout so sys.stdout has a specific encoding and errors behavior? Would this break other standard libraries that depend on sys.stdout being configured

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-14 Thread Chris Angelico
On Fri, Nov 14, 2014 at 9:58 PM, Steven D'Aprano wrote: > http://blog.codinghorror.com/why-cant-programmers-program/ > > Not everyone agrees that this is a thing: > > http://www.skorks.com/2010/10/99-out-of-100-programmers-cant-program-i-call-bullshit/ > > I'm inclined to accept that maybe 99 out

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-14 Thread Steven D'Aprano
Chris Angelico wrote: > There are blog posts out there about how large proportions of > applicants can't even write simple code on command... and I've taken > the questions and shown them to my siblings (who protest that they're > definitely not programmers), proving that a basic smattering of > m

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-13 Thread giacomo boffi
"Clayton Kirkwood" writes: > Although I suspect for a price you could bring all of your > professional programming jobs to somebody here, but I think you > would pay out more than you would make. s/ here/ else/ and your assumption can be falsified -- https://mail.python.org/mailman/listinfo/pyt

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-12 Thread Chris Angelico
On Wed, Nov 12, 2014 at 4:39 PM, Clayton Kirkwood wrote: > Chris, you're kidding, right? People get programming jobs without the > knowledge? How do they keep them? Don't hiring people look at code examples, > or previous employment? Ask relevant questions? Oh, I didn't say they *keep* the jobs,

RE: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-12 Thread Clayton Kirkwood
>-Original Message- >From: Python-list [mailto:python-list- >bounces+crk=godblessthe...@python.org] On Behalf Of Chris Angelico >Sent: Tuesday, November 11, 2014 12:36 AM >Cc: python-list@python.org >Subject: Re: I don't read docs and don't know how to use

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-11 Thread alister
On Mon, 10 Nov 2014 21:36:54 +, Denis McMahon wrote: > On Mon, 10 Nov 2014 10:56:18 -0800, sohcahtoa82 wrote: > >> ... I know software engineers make lots of money so I want to be one. > > I hear that pretty boy male escorts can make even more money than > software engineers. > > They also

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-11 Thread Chris Angelico
On Tue, Nov 11, 2014 at 10:21 AM, Clayton Kirkwood wrote: > Uh, how are you going to maintain a programming job if you don't know how to > program? I don't want to act but I know Brad Pitt makes lots of money doing > it, so I want to be Brad Pitt. Not! Not going to happen. Although I suspect > for

RE: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-11 Thread Clayton Kirkwood
>-Original Message- >From: Python-list [mailto:python-list- >bounces+crk=godblessthe...@python.org] On Behalf Of Grant Edwards >Sent: Monday, November 10, 2014 1:01 PM >To: python-list@python.org >Subject: Re: I don't read docs and don't know how to use

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-11 Thread Manolo Martínez
On 11/10/14 at 09:00pm, Grant Edwards wrote: > That's the saddest troll I've seen in ages. That, on the other hand, is a pretty decent bit of trolling. -- https://mail.python.org/mailman/listinfo/python-list

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread MRAB
On 2014-11-10 20:16, Ethan Furman wrote: On 11/10/2014 11:59 AM, Larry Martell wrote: On Mon, Nov 10, 2014 at 2:49 PM, Roy Smith wrote: In article , sohcahto...@gmail.com wrote: Please help me this assignment is due in an hour. Don't give me hints, just give me the answer because I only w

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread Ian Kelly
On Mon, Nov 10, 2014 at 2:45 PM, wrote: > On Monday, November 10, 2014 1:01:05 PM UTC-8, Grant Edwards wrote: >> On 2014-11-10, sohcahtoa82 wrote: >> >> > Please help me this assignment is due in an hour. Don't give me >> > hints, just give me the answer because I only want a grade. I'm not >>

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread sohcahtoa82
On Monday, November 10, 2014 1:01:05 PM UTC-8, Grant Edwards wrote: > On 2014-11-10, sohcahtoa82 wrote: > > > Please help me this assignment is due in an hour. Don't give me > > hints, just give me the answer because I only want a grade. I'm not > > actually interested in learning how to progra

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread Denis McMahon
On Mon, 10 Nov 2014 10:56:18 -0800, sohcahtoa82 wrote: > ... I know software engineers > make lots of money so I want to be one. I hear that pretty boy male escorts can make even more money than software engineers. They also don't need to learn how to program, which is something software engin

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread Grant Edwards
On 2014-11-10, sohcahto...@gmail.com wrote: > Please help me this assignment is due in an hour. Don't give me > hints, just give me the answer because I only want a grade. I'm not > actually interested in learning how to program, but I know software > engineers make lots of money so I want to b

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread Ethan Furman
On 11/10/2014 11:59 AM, Larry Martell wrote: On Mon, Nov 10, 2014 at 2:49 PM, Roy Smith wrote: In article , sohcahto...@gmail.com wrote: Please help me this assignment is due in an hour. Don't give me hints, just give me the answer because I only want a grade. I'm not actually interested

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread Mark Lawrence
On 10/11/2014 19:24, Peter Otten wrote: sohcahto...@gmail.com wrote: Please help me this assignment is due in an hour. Don't give me hints, just give me the answer because I only want a grade. I'm not actually interested in learning how to program, but I know software engineers make lots of m

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread Larry Martell
On Mon, Nov 10, 2014 at 2:49 PM, Roy Smith wrote: > In article , > sohcahto...@gmail.com wrote: > >> Please help me this assignment is due in an hour. Don't give me hints, just >> give me the answer because I only want a grade. I'm not actually interested >> in learning how to program, but I kn

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread Roy Smith
In article , sohcahto...@gmail.com wrote: > Please help me this assignment is due in an hour. Don't give me hints, just > give me the answer because I only want a grade. I'm not actually interested > in learning how to program, but I know software engineers make lots of money > so I want to

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread Peter Otten
sohcahto...@gmail.com wrote: > Please help me this assignment is due in an hour. Don't give me hints, > just give me the answer because I only want a grade. I'm not actually > interested in learning how to program, but I know software engineers make > lots of money so I want to be one. I'm sorr

I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread sohcahtoa82
Please help me this assignment is due in an hour. Don't give me hints, just give me the answer because I only want a grade. I'm not actually interested in learning how to program, but I know software engineers make lots of money so I want to be one. -- https://mail.python.org/mailman/listinfo

Re: print function and unwanted trailing space

2013-09-12 Thread Albert Hopkins
On Wed, Sep 11, 2013, at 07:36 AM, Wayne Werner wrote: > On Sat, 31 Aug 2013, candide wrote: > > # - > > for i in range(5): > >print(i, end=' ') # <- The last ' ' is unwanted > > print() > > # - > > Then why not define end='' instead?

Re: print function and unwanted trailing space

2013-09-11 Thread Wayne Werner
On Sat, 31 Aug 2013, candide wrote: # - for i in range(5): print(i, end=' ') # <- The last ' ' is unwanted print() # - Then why not define end='' instead? -W -- https://mail.python.org/mailman/listinfo/python-list

Re: print function and unwanted trailing space

2013-08-31 Thread Terry Reedy
On 8/31/2013 7:15 PM, Joshua Landau wrote: On 31 August 2013 23:08, Chris Angelico wrote: On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin wrote: On 31 August 2013 16:30, Chris Angelico wrote: but doesn't solve all the cases (imagine a string or an iterator). Similar but maybe simpler, and

Re: print function and unwanted trailing space

2013-08-31 Thread Joshua Landau
On 31 August 2013 23:08, Chris Angelico wrote: > On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin > wrote: >> On 31 August 2013 16:30, Chris Angelico wrote: but doesn't solve all the cases (imagine a string or an iterator). >>> >>> Similar but maybe simpler, and copes with more arbitrary

Re: print function and unwanted trailing space

2013-08-31 Thread Chris Angelico
On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin wrote: > On 31 August 2013 16:30, Chris Angelico wrote: >>> >>> but doesn't solve all the cases (imagine a string or an iterator). >> >> Similar but maybe simpler, and copes with more arbitrary iterables: >> >> it=iter(range(5)) >> print(next(it), en

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 15:59, Peter Otten a écrit : To make it crystal clear, the above was to illustrate the algorithm used in Python 2, not a suggestion. Ok sorry, I misinterpreted. > I still think you should live with a trailing space Are you sure ? The following code #

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 12:31, Peter Otten a écrit : with `softspace` saved as a file attribute, is gone in Python3. After reading http://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function I understand what you meant by "softspace". Thanks. -- http://mail.python.org/mailman/listinfo/python-l

Re: print function and unwanted trailing space

2013-08-31 Thread Oscar Benjamin
On 31 August 2013 16:30, Chris Angelico wrote: >> >> but doesn't solve all the cases (imagine a string or an iterator). > > Similar but maybe simpler, and copes with more arbitrary iterables: > > it=iter(range(5)) > print(next(it), end='') > for i in it: > print('',i, end='') If you want to w

Re: print function and unwanted trailing space

2013-08-31 Thread Chris Angelico
On Sat, Aug 31, 2013 at 11:33 PM, candide wrote: > The if instruction imposes useless testing (we know in advance the problem > to occur at the very end of the loop) and useless writing (writing ''). > > The following is clearer > > # - > n=5 > for i in range(n-1): > pr

Re: print function and unwanted trailing space

2013-08-31 Thread Steven D'Aprano
On Sat, 31 Aug 2013 14:59:17 +0200, candide wrote: > Le 31/08/2013 13:16, Steven D'Aprano a écrit : > > >> Of course it does. Have you actually tried it? > > > Of course I did, redirecting the output to a file in order to spot an > eventually trailing space. I did the same for the Python 3 cod

Re: print function and unwanted trailing space

2013-08-31 Thread Peter Otten
candide wrote: > Le 31/08/2013 12:31, Peter Otten a écrit : > > softspace = False > > for i in range(5): > > if softspace: > > print(end=" ") > > print(i, end="") > > softspace = True > > print() > > > The if instruction imposes useless testing (we know in advance

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 13:24, Ned Batchelder a écrit : For a beginner course, the trailing space is fine, use this code. I was really expecting there was a trick but I'll follow your advice, after all the trailing space is invisible! Nevertheless, this can be quite annoying. For instance, some autom

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 12:31, Peter Otten a écrit : > softspace = False > for i in range(5): > if softspace: > print(end=" ") > print(i, end="") > softspace = True > print() The if instruction imposes useless testing (we know in advance the problem to occur at the very end of the

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 13:16, Steven D'Aprano a écrit : Of course it does. Have you actually tried it? Of course I did, redirecting the output to a file in order to spot an eventually trailing space. I did the same for the Python 3 code. -- http://mail.python.org/mailman/listinfo/python-list

Re: print function and unwanted trailing space

2013-08-31 Thread Oscar Benjamin
On 31 August 2013 12:16, Steven D'Aprano wrote: > On Sat, 31 Aug 2013 10:17:23 +0200, candide wrote: > >> What is the equivalent in Python 3 to the following Python 2 code: >> >> # - >> for i in range(5): >> print i, >> # - >> >> ? >> >>

Re: print function and unwanted trailing space

2013-08-31 Thread Peter Otten
Steven D'Aprano wrote: > On Sat, 31 Aug 2013 10:17:23 +0200, candide wrote: > >> What is the equivalent in Python 3 to the following Python 2 code: >> >> # - >> for i in range(5): >> print i, >> # - >> >> ? >> >> Be careful that the

Re: print function and unwanted trailing space

2013-08-31 Thread Ned Batchelder
On 8/31/13 4:17 AM, candide wrote: What is the equivalent in Python 3 to the following Python 2 code: # - for i in range(5): print i, # - ? Be careful that the above code doesn't add a trailing space after the last number in the lis

Re: print function and unwanted trailing space

2013-08-31 Thread Steven D'Aprano
On Sat, 31 Aug 2013 10:17:23 +0200, candide wrote: > What is the equivalent in Python 3 to the following Python 2 code: > > # - > for i in range(5): > print i, > # - > > ? > > Be careful that the above code doesn't add a trailing spac

Re: print function and unwanted trailing space

2013-08-31 Thread Peter Otten
candide wrote: > Le 31/08/2013 10:43, Andreas Perstinger a écrit : > > > How about > > > > >>> print(" ".join(str(i) for i in range(5))) > > 0 1 2 3 4 > > > > > Thanks for your answer. The output is stricly the same but the code > doesn't suit my needs : > > 1) I'm porting to Python 3 a

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 10:43, Andreas Perstinger a écrit : > How about > > >>> print(" ".join(str(i) for i in range(5))) > 0 1 2 3 4 > Thanks for your answer. The output is stricly the same but the code doesn't suit my needs : 1) I'm porting to Python 3 a Python 2 full beginner course : the learner

Re: print function and unwanted trailing space

2013-08-31 Thread Andreas Perstinger
On 31.08.2013 10:17, candide wrote: What is the equivalent in Python 3 to the following Python 2 code: # - for i in range(5): print i, # - ? How about >>> print(" ".join(str(i) for i in range(5))) 0 1 2 3 4 Bye, Andreas -- ht

print function and unwanted trailing space

2013-08-31 Thread candide
What is the equivalent in Python 3 to the following Python 2 code: # - for i in range(5): print i, # - ? Be careful that the above code doesn't add a trailing space after the last number in the list, hence the following Python 3 code

Re: Print Function

2012-09-22 Thread Walter Hurry
On Sat, 22 Sep 2012 01:26:43 +, Steven D'Aprano wrote: > On Fri, 21 Sep 2012 13:20:09 -0700, gengyangcai wrote: > >> I am currently using Python 3.2.3 . WHen I use the print function by >> typing print "Game Over" , it mentions " SyntaxError : inval

Re: Print Function

2012-09-22 Thread Mark Lawrence
On 22/09/2012 02:26, Steven D'Aprano wrote: On Fri, 21 Sep 2012 13:20:09 -0700, gengyangcai wrote: I am currently using Python 3.2.3 . WHen I use the print function by typing print "Game Over" , it mentions " SyntaxError : invalid syntax ". Any ideas on what the prob

Re: Print Function

2012-09-21 Thread Steven D'Aprano
On Fri, 21 Sep 2012 13:20:09 -0700, gengyangcai wrote: > I am currently using Python 3.2.3 . WHen I use the print function by > typing print "Game Over" , it mentions " SyntaxError : invalid syntax > ". Any ideas on what the problem is and how to resolve it ? N

Re: Print Function

2012-09-21 Thread Ian Kelly
On Fri, Sep 21, 2012 at 3:11 PM, Alister wrote: > On Fri, 21 Sep 2012 14:54:14 -0600, Ian Kelly wrote: > >> On Fri, Sep 21, 2012 at 2:28 PM, Rodrick Brown >> wrote: >>> Go away troll! >> >> Troll? It looked like a sincere question to me. > > but one that page 1 of the documentation would answer.

Re: Print Function

2012-09-21 Thread John Gordon
In gengyang...@gmail.com writes: > I am currently using Python 3.2.3 . WHen I use the print function by > typing print "Game Over" , it mentions " SyntaxError : invalid syntax ". > Any ideas on what the problem is and how to resolve it ? Thanks a lot . In python

Re: Print Function

2012-09-21 Thread Alister
On Fri, 21 Sep 2012 14:54:14 -0600, Ian Kelly wrote: > On Fri, Sep 21, 2012 at 2:28 PM, Rodrick Brown > wrote: >> Go away troll! > > Troll? It looked like a sincere question to me. but one that page 1 of the documentation would answer. -- Waste not, get your budget cut next year. -- http:/

Re: Print Function

2012-09-21 Thread Ian Kelly
On Fri, Sep 21, 2012 at 2:28 PM, Rodrick Brown wrote: > Go away troll! Troll? It looked like a sincere question to me. -- http://mail.python.org/mailman/listinfo/python-list

Re: Print Function

2012-09-21 Thread Rodrick Brown
Go away troll! Sent from my iPhone On Sep 21, 2012, at 4:27 PM, "gengyang...@gmail.com" wrote: > Hello , > > > I am currently using Python 3.2.3 . WHen I use the print function by typing > print "Game Over" , it mentions " SyntaxError : invalid syntax

Re: Print Function

2012-09-21 Thread Tarek Ziadé
On 9/21/12 10:20 PM, gengyang...@gmail.com wrote: Hello , I am currently using Python 3.2.3 . WHen I use the print function by typing print "Game Over" , it mentions " SyntaxError : invalid syntax ". Any ideas on what the problem is and how to resolve it ? Thanks a

Print Function

2012-09-21 Thread gengyangcai
Hello , I am currently using Python 3.2.3 . WHen I use the print function by typing print "Game Over" , it mentions " SyntaxError : invalid syntax ". Any ideas on what the problem is and how to resolve it ? Thanks a lot . GengYang -- http://mail.python.org/mailman/listinfo/python-list

Re: Globally override built-in print function?

2010-04-16 Thread J. Cliff Dyer
On Fri, 2010-04-16 at 09:50 -0700, Dave W. wrote: > >>> old_print = __builtins__.print > >>> __builtins__.print = printhook > >>> yield > >>> __builtins__.print = old_print > > > >> I'm pretty sure this is semantically equivalent to my original > >> code, but I gave it a try anyway.

Re: Globally override built-in print function?

2010-04-16 Thread Dave W.
>>> old_print = __builtins__.print >>> __builtins__.print = printhook >>> yield >>> __builtins__.print = old_print > >> I'm pretty sure this is semantically equivalent to my original >> code, but I gave it a try anyway. > > Not at all. Declaring "global print" then assigning to "pri

Re: Globally override built-in print function?

2010-04-16 Thread Robert Kern
On 2010-04-15 21:17 PM, Dave W. wrote: I naively thought I could capture output from exec()'ed print invocations by (somehow) overriding 'print' globally. But this seems not to be possible. old_print = __builtins__.print __builtins__.print = printhook yield __builtins__.print

Re: Globally override built-in print function?

2010-04-16 Thread Lie Ryan
lier...@compaq ~/junks $ python3 printhook.py Python 3.1.2 (r312:79147, Apr 16 2010, 16:58:34) [GCC 4.3.4] linux2 Type "help", "copyright", "credits" or "license" for more info. >>> print(32) printhook(): 32 Note that assigning to __builtins__.p

Re: Globally override built-in print function?

2010-04-16 Thread Peter Otten
Dave W. wrote: > I naively thought I could capture output from exec()'ed print > invocations by (somehow) overriding 'print' globally. But this > seems not to be possible. Or at least not easy: Assigning a new function to the global print name affects only print() calls within your script, not

Re: Globally override built-in print function?

2010-04-15 Thread Dave W.
> > I naively thought I could capture output from exec()'ed print > > invocations by (somehow) overriding 'print' globally. But this > > seems not to be possible. > >old_print = __builtins__.print >__builtins__.print = printhook >yield >__builtins__.print = old_print I'm pretty

Re: Globally override built-in print function?

2010-04-15 Thread Robert Kern
[MSC v.1500 32 bit (Intel)] win32 Type "help", "copyright", "credits" or "license" for more info. print("Hello?") Hello? My custom print function isn't being called (see code below), I guess because its only being overridden in the cur

Globally override built-in print function?

2010-04-15 Thread Dave W.
"help", "copyright", "credits" or "license" for more info. >>> print("Hello?") Hello? >>> My custom print function isn't being called (see code below), I guess because its only being overridden in the current module? Is ther

Re: print function in python3.1

2009-11-23 Thread Terry Reedy
Dennis Lee Bieber wrote: Does Python 3.x include SQLite? Of course ;-] >>> import sqlite3 >>> dir(sqlite3) ['Binary', 'Cache', 'Connection', 'Cursor', 'DataError', [snip] adapt', 'adapters', 'apilevel', 'complete_statement', 'connect', 'converters', 'datetime', 'dbapi2', 'enable_callback_tr

Re: print function in python3.1

2009-11-23 Thread Diez B. Roggisch
Anjanesh Lekshminarayanan wrote: >> Maybe it would help if you explained what you are actually trying to >> accomplish. > > import csv > f = csv.reader(open('data.txt'), delimiter='\t') # 2GB text file > sql = "INSERT INTO `data` VALUES (NULL,%s,%s,%s,%s,%s);" > for row in f: > print (sql, (r

Re: print function in python3.1

2009-11-23 Thread Anjanesh Lekshminarayanan
> Maybe it would help if you explained what you are actually trying to > accomplish. import csv f = csv.reader(open('data.txt'), delimiter='\t') # 2GB text file sql = "INSERT INTO `data` VALUES (NULL,%s,%s,%s,%s,%s);" for row in f: print (sql, (row[0],row[1],row[2],row[3],row[4])) $ python3 p

Re: print function in python3.1

2009-11-23 Thread Carsten Haese
Anjanesh Lekshminarayanan wrote: > As of now, there is no mysql adaptor for Python3. Hence cant use > escape_string() Maybe it would help if you explained what you are actually trying to accomplish. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/p

Re: print function in python3.1

2009-11-23 Thread Anjanesh Lekshminarayanan
As of now, there is no mysql adaptor for Python3. Hence cant use escape_string() > I don't have the slightest clue what you want to say with that. -- Anjanesh Lekshmnarayanan -- http://mail.python.org/mailman/listinfo/python-list

Re: print function in python3.1

2009-11-23 Thread Diez B. Roggisch
Anjanesh Lekshminarayanan wrote: >> Depending on your DB-adapter, you are out of luck here. Either connect to >> a db even if you don't need it, or try & see if you can locate the >> implementation in the module somehow. > > ImportError: No module named MySQLdb > MySQLdb only available in Python2

Re: print function in python3.1

2009-11-23 Thread Anjanesh Lekshminarayanan
> Depending on your DB-adapter, you are out of luck here. Either connect to a > db even if you don't need it, or try & see if you can locate the > implementation in the module somehow. ImportError: No module named MySQLdb MySQLdb only available in Python2. -- Anjanesh Lekshmnarayanan -- http:

Re: print function in python3.1

2009-11-23 Thread Diez B. Roggisch
Anjanesh Lekshminarayanan wrote: > Python 3.1.1 > > sql = "INSERT INTO `tbl` VALUES (NULL, '%s', '%s', '%s', '%s', '%s');" > for row in fp: > print (sql, (row[0],row[1],row[2],row[3],row[4])) > . > INSERT INTO `tbl` VALUES (NULL, '%s', '%s', '%s', '%s', '%s'); ('142', > 'abc', '2006-04-09 02:

  1   2   >