[Zope] making 'printed' = ''

Lennart Regebro lennart@regebro.nu
Wed, 12 Dec 2001 23:08:51 +0100


From: "Christopher N. Deckard" <cnd@ecn.purdue.edu>
> Is it possible to do something like this:
>
>   print 'foo'
>   print 'more foo'
>   print 'I like foo'
>
>   thing = printed
>   printed = ''
>
>   print 'bar'
>   print 'more bar'
>
> otherthing = printed

If you initialize printed to something before you set thing to it, yes. But
why?

> I want to do this because I want the new line at the end of each
> line and don't want to put "\n"'s everywhere.  Is it possible to do
> that?

You get a newline at the end of each line... Do you mean you want two?
Then do:
def mp( this):
    print this
    print

and use mp 'bar' instead. That way you save a whopping 5 characters per
line, so you actually start saving your typing skills after ten lines or so,
and you have obfuscated things a lot.

Or, you can
print """This is a multiline
text that
spans several lines. Cool
Eh?"""

> Or am I just insane.

Quite likely yes. :-)

> Zope tells me that 'printed' is a reserved word.

Printed? Ah, well, then call it something else. :-)
It doesn't do anything in your example above. :-)