PEP 214 - Why not print >> string?

Steve Holden sholden at holdenweb.com
Fri Jan 11 09:17:38 EST 2002


"Aaron Swartz" <me at aaronsw.com> wrote...
> On 2002-10-01 1:08 PM, in article
yu99d70it45b.fsf at europa.research.att.com,
> "Andrew Koenig" <ark at research.att.com> wrote:
>
> > So
> >       x = ''
> >       print >> x, 3
> >       print >> x, 3
> >
> > would cause x to be '3 3'?  Or would it be '3\n3\n' ?
>
> The latter, as the normal print rules will apply (of course the \ns could
be
> suppressed by a trailing ',').
>
> > What if I forgot to say  x = ''  first?
>
> The same thing that happens now, namely:
>
> >>> print >> foo, a
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> NameError: name 'foo' is not defined
>
> Or
>
> >>> x = 2
> >>> print >> x, 'a'
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'int' object has no attribute 'write'
>
> (perhaps a better error could be given, but the idea is the same)

So does your proposal actually include the addition of a "write" method to
strings?

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list