Re: [Tutor] Help with vars()
by Charlie Clark other posts by this author
Aug 10 2001 9:33AM messages near this date
Re: [Tutor] Help with vars()
|
Re: [Tutor] Help with vars()
> Start screaming. *grin* We won't need to call vars() at all: we can just
> do the interpolation directly with the dictionary that's in our hands:
>
> ###
> >>> insert = "%(headline)s, %(text)s, %(sternzeichen)s" % articles
> >>> print insert
> Horoskop fr Peter, Es wird besser, Wassermann
> ###
>
>
> Note: the string formatting above requires us to put the variables in the
> '%(foo)s' sorta format --- the trailing 's' doesn't stand for plurality,
> but for 'string'ality.
>
> Hope this helps!
Yes, it does but it's confusing and isn't explicit in the documentation.
%s(name) or %d(name) would make more sense to me.
Charlie
_______________________________________________
Tutor maillist - Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Charlie Clark
Danny Yoo
Steven Burr
Charlie Clark
Steven Burr
Charlie Clark
lonetwin
Charlie Clark
Steven Burr
|