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
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
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
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
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)
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
> 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
print "a"+"b"
\d
--
http://mail.python.org/mailman/listinfo/python-list
> 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
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
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
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
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
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
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.
>
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
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
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
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
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.
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
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
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.
.
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
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
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
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
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
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
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
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
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
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
33 matches
Mail list logo