> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of John Machin > Sent: Wednesday, January 09, 2008 3:02 PM > To: python-list@python.org > Subject: Re: problem of converting a list to dict > > On Jan 10, 6:52 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > > > A bigger hint: > > a=i.split('=') > > print "'%s' splits into " % (i), a > > consider: > (1) using %r instead of '%s'
Eh, personal preference depending on how sure you are of the data's type. > (2) omitting the redundant space after 'into' Some of us coming in from other languages and still aren't used to the comma adding an unwanted space after everything. I've been tempted to root around in Python's source code to fix the problem. > (3) losing the redundant () around i For me, the () is there for readability. Python's sprintf syntax is odd to begin with, and something like print "'%s' splits into " % i, a, b, c means either 1) you really do want to append b and c after the sprintf, or print "'%s' splits into " % (a), b, c 2) that the formatting string is missing a few things print "'%s' splits into " % (a, b, c) ## Ooops! forgot to change it to "%s %5.2d %6.3f" ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622 -- http://mail.python.org/mailman/listinfo/python-list