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"); > > #} > >

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
On Thu, Aug 4, 2016 at 1:35 AM, Malcolm Greene wrote: > 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

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 encoding and errors behavior?

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? Would this break > oth

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

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 : invalid syntax >> ". Any ideas on what the prob

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 problem is and how to resolve

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 ? No, none what so ever. Perhaps you

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 version 3, print was changed i

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 ". Any ideas > on what the problem is a

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 lot . print was a stat

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:

Re: print function question

2006-07-25 Thread Simon Forman
Bertrand-Xavier M. wrote: > On Tuesday 25 July 2006 05:52, Eric Bishop wrote: > > Why does this work: > > > > # start > > a = 5 > > > > print a, 'is the number' > > > > #end, prints out "5 is the number" > > > > But not this: > > > > # start > > > > a = 5 > > > > print a 'is the number' > > > > #en

Re: print function question

2006-07-24 Thread Bertrand-Xavier M.
On Tuesday 25 July 2006 05:52, Eric Bishop wrote: > Why does this work: > > # start > a = 5 > > print a, 'is the number' > > #end, prints out "5 is the number" > > But not this: > > # start > > a = 5 > > print a 'is the number' > > #end, errors out > > The difference here is the comma seperating th