Re: print without ()

2017-09-06 Thread Glenn Hutchings
On Thursday, 7 September 2017 07:14:57 UTC+1, Andrej Viktorovich wrote: > Sometimes I find code with strange print function usage. String is passed > without brackets. > > #!/usr/bin/python > list = ['physics', 'chemistry', 1997, 2000]; > print "Value available at index 2 : " > print list[2] > l

Re: print without ()

2017-09-06 Thread Jan Erik Moström
On 7 Sep 2017, at 8:14, Andrej Viktorovich wrote: If I use command print "aaa" in console I get error. So, why this is allowed in sample? You're probably using Python 2 for the listed script and Python 3 when you try in the console. = jem -- https://mail.python.org/mailman/listinfo/python-l

print without ()

2017-09-06 Thread Andrej Viktorovich
Hello, Sometimes I find code with strange print function usage. String is passed without brackets. #!/usr/bin/python list = ['physics', 'chemistry', 1997, 2000]; print "Value available at index 2 : " print list[2] list[2] = 2001; print "New value available at index 2 : " print list[2] If I use

Re: How to print without spaces?

2009-09-18 Thread Wolfgang Rohdewald
On Friday 18 September 2009, koranthala wrote: > What if I want to print 1 to 100 in a loop without spaces in > between? I think that is the OPs question. arr = ['a', 'b', 'c', 'andsoon'] print ''.join(arr) -- Wolfgang -- http://mail.python.org/mailman/listinfo/python-list

Re: How to print without spaces?

2009-09-18 Thread Jerry Hill
On Fri, Sep 18, 2009 at 4:16 PM, koranthala wrote: > What if I want to print 1 to 100 in a loop without spaces in between? > I think that is the OPs question. In that case I would skip using print entirely, and use something like this: import sys for i in xrange(100): sys.stdout.write(str(i)

Re: How to print without spaces?

2009-09-18 Thread koranthala
On Sep 18, 9:49 pm, "Andreas Tawn" wrote: > > Hi, > > > I don't want to print the space between 'a' and 'b'. Could somebody > > let me know how to do it? > > > Regards, > > Peng > > > $ python > > Python 2.5.2 (r252:60911, May 21 2008, 10:08:24) > > [GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux

Re: How to print without spaces?

2009-09-18 Thread Tobiah
> I don't want to print the space between 'a' and 'b'. Could somebody let me > know how to do it? print "a","b" > a b Since you are new, you should also be aware of: print "%s%s" % (a, b) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to print without spaces?

2009-09-18 Thread Donn
print "a"+"b" \d -- http://mail.python.org/mailman/listinfo/python-list

RE: How to print without spaces?

2009-09-18 Thread Andreas Tawn
> Hi, > > I don't want to print the space between 'a' and 'b'. Could somebody > let me know how to do it? > > Regards, > Peng > > $ python > Python 2.5.2 (r252:60911, May 21 2008, 10:08:24) > [GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2 > Type "help", "copyright", "credits" or "license" for

How to print without spaces?

2009-09-18 Thread Peng Yu
Hi, I don't want to print the space between 'a' and 'b'. Could somebody let me know how to do it? Regards, Peng $ python Python 2.5.2 (r252:60911, May 21 2008, 10:08:24) [GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> p

Re: print without newline "halts" program execution

2006-04-15 Thread Karlo Lozovina
Jay Parlar <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Your problem is that the 'print' statement is sending the text to > sys.stdout, and sys.stdout is buffered. I thought it was something like this, but I couldn't find it in the docs : (. > print 'Start: %f,'% st, > sys.stdout.flu

Re: print without newline "halts" program execution

2006-04-13 Thread Jay Parlar
On Apr 13, 2006, at 5:57 PM, Karlo Lozovina wrote: > Consider this short script: > > --- > from time import time, sleep > > st = time() > print 'Start: %f, ' % st, > sleep(10) > sp = time() > print 'Stop: %f, Duration: %f' % (sp, (st - sp)) > --- > > On my environment (Linux, py24), when run, Pyt

print without newline "halts" program execution

2006-04-13 Thread Karlo Lozovina
Consider this short script: --- from time import time, sleep st = time() print 'Start: %f, ' % st, sleep(10) sp = time() print 'Stop: %f, Duration: %f' % (sp, (st - sp)) --- On my environment (Linux, py24), when run, Python first waits 10s, and then produces the entire output. How, can I make i

Re: how to print without blank?

2006-04-09 Thread Ju Hui
thank you all. IT's very helpful to me. >>> import sys >>> def no_space_before(x): ... sys.stdout.softspace = 0 ... return x ... >>> for x in range(3): ... print no_space_before(x), ... 012 -- http://mail.python.org/mailman/listinfo/python-list

Re: how to print without blank?

2006-04-09 Thread Rick Zantow
Steven D'Aprano <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On Sat, 08 Apr 2006 22:54:17 -0700, Ju Hui wrote: > >> I want to print 3 numbers without blank. > [snip] >> how to print >> 012 >> ? > > Method one: accumulate your numbers into a single string, then print > it in one go. >

Re: how to print without blank?

2006-04-09 Thread Steven D'Aprano
On Sat, 08 Apr 2006 22:54:17 -0700, Ju Hui wrote: > I want to print 3 numbers without blank. [snip] > how to print > 012 > ? Method one: accumulate your numbers into a single string, then print it in one go. >>> L = [] >>> for x in range(3): ... L.append(str(x)) ... >>> print ''.join(L) 012

Re: how to print without blank?

2006-04-08 Thread Ivan Herman
Ju Hui wrote: > I want to print 3 numbers without blank. for x in range(3): > ... print x > ... > 0 > 1 > 2 for x in range(3): > ... print x, > ... > 0 1 2 > > how to print > 012 > ? > > thanks. > You may want to use the write command with stdout: sys.stdout.write("%s

how to print without blank?

2006-04-08 Thread Ju Hui
I want to print 3 numbers without blank. >>> for x in range(3): ... print x ... 0 1 2 >>> for x in range(3): ... print x, ... 0 1 2 how to print 012 ? thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: pre-PEP: Print Without Intervening Space

2005-03-15 Thread Thomas Bellman
Antoon Pardon <[EMAIL PROTECTED]> wrote: > For instance if I do the following >a = 1, > I have assigned a one element tuple to a. > But if I do >print 1, > It doesn't print a one element tuple. And if you do parrot(1,) you won't call parrot() with a one-element tuple eit

Re: pre-PEP: Print Without Intervening Space

2005-03-15 Thread Antoon Pardon
Op 2005-03-11, Marcin Ciura schreef <[EMAIL PROTECTED]>: > Moreover, all of them require creating one or two temporary > objects to hold the entire result. If the programmers use one of > them without qualms, it is only because their mind is warped by > the limitation of print.

Re: pre-PEP: Print Without Intervening Space

2005-03-12 Thread Marcin Ciura
Bengt Richter wrote: BTW, what makes you think any self-respecting "scientist" wouldn't be insulted by the idea of your spoon-feeding them a dumbed-down programming equivalent of "See Spot run"? Am I right thinking that your dream 3 R's curriculum starts with "Stately, plump Buck Mulligan" and Póly

Re: pre-PEP: Print Without Intervening Space

2005-03-12 Thread huy
Marcin Ciura wrote: Duncan Booth wrote: import sys def nospace(value, stream=None): '''Suppress output of space before printing value''' stream = stream or sys.stdout stream.softspace = 0 return str(value) I'm teaching Python as the first programming language to non-computer scient

Re: pre-PEP: Print Without Intervening Space

2005-03-12 Thread Marcin Ciura
Steve Holden wrote: You could think about teaching them the linelist.append(fn(x)) way, which then gives you the choice of "".join(linelist) - no gaps "\n".join(lienlist) - one item per line " ".join(linelist) - spaces between items. Sure I will. Next week, when we come to list operations. .

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Bengt Richter
On Fri, 11 Mar 2005 10:59:16 -0500, Steve Holden <[EMAIL PROTECTED]> wrote: >Marcin Ciura wrote: >> Duncan Booth wrote: >> >>> import sys >>> def nospace(value, stream=None): >>> '''Suppress output of space before printing value''' >>> stream = stream or sys.stdout >>> stream.softspac

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Marcin Ciura
In view of Duncan's response, which invalidates the premises of my proposal, I announce the end of its short life. I will add Duncan's solution to my bag of tricks - thank you! Marcin -- http://mail.python.org/mailman/listinfo/python-list

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Steve Holden
Marcin Ciura wrote: Duncan Booth wrote: import sys def nospace(value, stream=None): '''Suppress output of space before printing value''' stream = stream or sys.stdout stream.softspace = 0 return str(value) I'm teaching Python as the first programming language to non-computer scient

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread John Roth
that I wrote recently. Please let me know what is the community's opinion on it. Cheers, Marcin PEP: XXX Title: Print Without Intervening Space Version: $Revision: 0.0 $ Author: Marcin Ciura Status: Draft Type: Standards Track Created: 11-Mar-2005 Post-History: 11-Mar-2005 Abstract This

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Bill Mill
On Fri, 11 Mar 2005 10:00:03 -0600, Larry Bates <[EMAIL PROTECTED]> wrote: > > I also don't miss a no-space option on print. I've always believed > that print statements with commas in them were for simple output with > little or no regard for formatting (like for debugging statements). > If I wa

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Marcin Ciura
Larry Bates wrote: I fail to see why your proposed solution of: for x in seq: print fn(x),, print is clearer than: print ''.join([fn(x) for x in seq]) Thank you for your input. The latter form is fine with me personally, but you just can't explain it to complete novices. My prop

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Larry Bates
Marcin Ciura wrote: > Here is a pre-PEP about print that I wrote recently. > Please let me know what is the community's opinion on it. > > Cheers, > Marcin > > > PEP: XXX > Title: Print Without Intervening Space > Version: $Revision: 0.0 $ > Author

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Marcin Ciura
Duncan Booth wrote: import sys def nospace(value, stream=None): '''Suppress output of space before printing value''' stream = stream or sys.stdout stream.softspace = 0 return str(value) I'm teaching Python as the first programming language to non-computer scientists. Many of the toy

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Duncan Booth
Marcin Ciura wrote: > None of the more efficient solutions is particularly > straightforward, either: > > result = [] > for x in seq: > result.append(fn(x)) > print ''.join(result) > > print ''.join([fn(x) for x in seq]) > > pr

pre-PEP: Print Without Intervening Space

2005-03-11 Thread Marcin Ciura
Here is a pre-PEP about print that I wrote recently. Please let me know what is the community's opinion on it. Cheers, Marcin PEP: XXX Title: Print Without Intervening Space Version: $Revision: 0.0 $ Author: Marcin Ciura Status: Draft Type: Standards Track Created: 11-Mar-2005 Post-Histor