Translating a Perl script into Python
Sheila King
sheila at thinkspot.net
Sun Jan 21 00:30:03 EST 2001
On Sun, 21 Jan 2001 01:22:40 GMT, Hamish Lawson <hamish_lawson at yahoo.co.uk>
wrote in comp.lang.python in article <94ddks$ff9$1 at nnrp1.deja.com>:
:It's more general and more powerful than that. The % operator takes a
:string on the left and a single value, tuple, list or dictionary on the
:right and produces a string by substituting the % placeholders in the
:left-hand operand with values from the right-hand operand. Note that %
:inside a string doesn't have any special meaning in itself; it's the %
:operator that treats it as placeholder. Thus
:
: a = "His name is %s and his age is %d"
: b = ['Bob', 42]
: print a % b
Thanks. I think it's starting to creep into my head, now. Your examples
helped. I've saved them in my file of examples.
--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/
More information about the Python-list
mailing list