>> dictionary-key/value syntax), you can do something like:
> number = lambda x: dict((str(i+1), v) for (i,v) in enumerate(x))
> "%(2)s and %(1)s" % number(["A", "B"])
>
> Whoa - that'll take me a little while to figure out, but it looks intriguing!
It basically just returns a dictionary
> dictionary-key/value syntax), you can do something like:
> >>> number = lambda x: dict((str(i+1), v) for (i,v) in enumerate(x))
> >>> "%(2)s and %(1)s" % number(["A", "B"])
Whoa - that'll take me a little while to figure out, but it looks intriguing!
Tah.
\d
--
http://mail.python.org/mailman/l
> I'm sure I one read somewhere that there is a simple way to set the order
> of replacements withing a string *without* using a dictionary.
>
> What I mean is:
s = "%s and %s" % ( "A", "B" )
print s
> A and B
>
> Now, is there something quick like:
s = "%s/2 and %s/1" % ( "A", "B
try to import printf using ctypes
On Dec 2, 2007 7:49 PM, MRAB <[EMAIL PROTECTED]> wrote:
> On Dec 2, 1:35 pm, Donn Ingle <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I'm sure I one read somewhere that there is a simple way to set the
> order
> > of replacements withing a string *without* using a dict
On Dec 2, 1:35 pm, Donn Ingle <[EMAIL PROTECTED]> wrote:
> Hi,
> I'm sure I one read somewhere that there is a simple way to set the order
> of replacements withing a string *without* using a dictionary.
>
> What I mean is:>>> s = "%s and %s" % ( "A", "B" )
> >>> print s
>
> A and B
>
> Now, is th
> but not Python, AFAIK
Damn!
\d
--
http://mail.python.org/mailman/listinfo/python-list
Donn Ingle wrote:
> Now, is there something quick like:
s = "%s/2 and %s/1" % ( "A", "B" )
print s
> B and A
>
> ?
GNU glibc printf accepts a format string:
printf ("%2$s and %1$s", "A", "B");
to produce what you want -- but not Python, AFAIK.
Mel.
--
http://mail.python.o