On 15 January 2013 23:12, Rohit Mediratta <rohit_m...@hotmail.com> wrote: > Hi, > I am using Centos 6.3 and python 2.6.6. > > When I try to assign a variables value inside a multiple line message, it > does not work. > >>>>cardName = "ActualCardName" >>>>data = """ <inst dn="root/child"> > <card name=%cardName descr="testingAgain"> """ >>>> print data > <inst dn="root/child"> > <card name=%cardName descr="testingAgain"> > > > I would like %cardName to be replaced by "actualCardName". As you can see I > am trying to use XML and therefore I will have several such replacements > that I will need to do.
How about this? >>> data = """ <inst dn="root/child"> ... <card name=%(cardName)s descr="testingAgain"> """ >>> >>> print data <inst dn="root/child"> <card name=%(cardName)s descr="testingAgain"> >>> print data % {'cardName':'actualCardName'} <inst dn="root/child"> <card name=actualCardName descr="testingAgain"> Oscar _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor