On Sep 5, 1:51 am, Dero wrote:
> On Sep 5, 2:35 pm, "Mark Tolonen" wrote:
>
> > "DarkBlue" wrote in message
>
> >news:b9c0c4ac-5f8f-4133-b928-9e55ab4b2...@x5g2000prf.googlegroups.com...
>
> > >I am trying to get used to the new print() syntax prior to installing
> > > python 3.1:
...
> > Without
On Sep 5, 2:35 pm, "Mark Tolonen" wrote:
> "DarkBlue" wrote in message
>
> news:b9c0c4ac-5f8f-4133-b928-9e55ab4b2...@x5g2000prf.googlegroups.com...
>
>
>
> >I am trying to get used to the new print() syntax prior to installing
> > python 3.1:
>
> > test=[["VG", "Virgin Islands, British"],["VI", "
"DarkBlue" wrote in message
news:b9c0c4ac-5f8f-4133-b928-9e55ab4b2...@x5g2000prf.googlegroups.com...
I am trying to get used to the new print() syntax prior to installing
python 3.1:
test=[["VG", "Virgin Islands, British"],["VI", "Virgin Islands, U.S."],
["WF", "Wallis and Futuna"],["EH", "We
"DarkBlue" wrote in message
news:b9c0c4ac-5f8f-4133-b928-9e55ab4b2...@x5g2000prf.googlegroups.com...
I am trying to get used to the new print() syntax prior to installing
python 3.1:
test=[["VG", "Virgin Islands, British"],["VI", "Virgin Islands, U.S."],
["WF", "Wallis and Futuna"],["EH", "We
> >>> import cStringIO
> >>> s = cStringIO.StringIO()
> >>> print >>s, [1, 2, 1.0/5, 'hello world']
> >>> s.getvalue()
Thanks--this works perfectly!
-_Steve
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 31 Oct 2007 22:17:48 +, mrstephengross wrote:
> I would like to get the results of a print operation placed in a string.
s = str(x)
If you specifically need to capture the output of print, then something
like this:
>>> import cStringIO
>>> s = cStringIO.StringIO()
>>> print >>s,
mrstephengross a écrit :
> I would like to get the results of a print operation
print is a statement, it doesn't yield any 'result'.
> placed in a
> string. For instance, you can very easily create a list and print it
> to stdout:
>
> x = [1,2,3]
> print x # Will print [1,2,3]
>
> What if
mrstephengross wrote:
> I would like to get the results of a print operation placed in a
> string. For instance, you can very easily create a list and print it
> to stdout:
>
> x = [1,2,3]
> print x # Will print [1,2,3]
>
> What if I want the text "[1,2,3]" placed in a string? For instance,
> s