Re: String formatting with %s

2007-12-03 Thread Tim Chase
>> 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

Re: String formatting with %s

2007-12-02 Thread Donn
> 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

Re: String formatting with %s

2007-12-02 Thread Tim Chase
> 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

Re: String formatting with %s

2007-12-02 Thread James Matthews
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

Re: String formatting with %s

2007-12-02 Thread MRAB
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

Re: String formatting with %s

2007-12-02 Thread Donn Ingle
> but not Python, AFAIK Damn! \d -- http://mail.python.org/mailman/listinfo/python-list

Re: String formatting with %s

2007-12-02 Thread Mel
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