Oops, those should have been () not {}

> msg = '''
> A very long string that overspills
> onto multiple lines and includes
> my name which is %(name)s
> and a number which is my age: %(age)d
> '''
>
> print msg % vars()

Sorry folks, I really should try these things *before*
I hit the send button...


Alan G.

----- Original Message ----- 
From: "Alan Gauld" <[EMAIL PROTECTED]>
To: "Michael Powe" <[EMAIL PROTECTED]>; <tutor@python.org>
Sent: Monday, January 03, 2005 11:54 PM
Subject: Re: [Tutor] here documents


> There was a detailed thread on this recently either here
> or on usenet group comp.lang.python...
>
> The bottom line was to use string formatting and triple
> quoted strings...
>
> msg = '''
> A very long string that overspills
> onto multiple lines and includes
> my name which is %{name}s
> and a number which is my age: %{age}d
> '''
>
> print msg % vars()
>
> HTH,
>
> Alan G.
>
> ----- Original Message ----- 
> From: "Michael Powe" <[EMAIL PROTECTED]>
> To: <tutor@python.org>
> Sent: Monday, January 03, 2005 10:54 PM
> Subject: [Tutor] here documents
>
>
> > Hello,
> >
> > In perl, I create variables of fairly involved text using here
> > documents.  For example,
> >
> > $msg = <<"EOF";
> >   a bunch of text here.
> >   ...
> > EOF
> >
> > Is there an equivalent method in python?  I usually use this
method
> > when creating help messages for scripts -- put all the text into a
> > variable and the 'print $msg' for the output.  I find it an easy
way
> > to produce formatted text.
> >
> > Now, I'm trying to switch over to python and want to recreate or
> adapt
> > my processes.
> >
> > Thanks.
> >
> > mp
> >
> >
>

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to