Variables.

Simon Brunning simon.brunning at gmail.com
Tue Feb 15 07:39:10 EST 2005


On Tue, 15 Feb 2005 04:30:30 -0800 (PST), administrata
<administrata at hotmail.com> wrote:
> I wrote this, It's a bit lame though
> 
> I = "Allen"
> me = "Allen"
> my = "Allen's"
> 
> print \
> """
> %s woke up early in the morning. But, it was unusal by %s. %s pillow
> was with %s. %s didn't want to wake up But, %s tried my best and woke up.
> it was so amazing!""" % (I,me,my,me,I,I)

One thing that you might want to do is to use a dictionary to provide
the values, like so:

my_values = {"I": "Simon", "me": "Simon", "my": "Simon's"}

print """%(I)s woke up early in the morning. But, it was unusal by
%(me)s. %(my)s pillow
was with %(me)s. %(I)s didn't want to wake up But, %(I)s tried my best
and woke up.
It was so amazing!""" % my_values

> raw_input("\n\\t\t\t- The End -")
> 
> But it looks like this...
> 
> Allen woke up early in the morning. But, it was unusal by Allen.
> Allen's pillow
> was with Allen. Allen didn't want to wake up But, Allen tried my best and woke up.
> it was so amazing
> 
>                             - The End -

What did you *expect* it to do?

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list