Rohit Mediratta 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.
> 


data = """ <inst dn="root/child">
       <card name={0} descr="testingAgain"> """.format( cardName )

See here for more information on formatting syntax.
http://docs.python.org/2/library/string.html#formatstrings

> 
> If someone can suggest a clean way for me to achieve my goal, that would be 
> great.
> 
> Please note, my input is going to be several lines long.
> 
> thanks,
> Rohit


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to