Simple Problems: Caps and Commas
KefX
keflimarcusx at aol.comNOSPAM
Mon Oct 27 02:54:33 EST 2003
># lower() is a string method, the in operator tests for list membership
>if poan.lower() in ['yes', 'y', 'yup', 'ja']:
Yeah, that's probably better than my suggestion of string.lower(poan)...I
should have checked to see if that's a string method first.
># the % operator does 'string interpolation' and gives you more control
># over the outputstring
>print 'Name: %s, %s, %s' % (fname, mname, lname)
This is just overkill. No "string interpolation" is needed here, just the
programmer inserted extra spaces and didn't expect the print statement to print
spaces AFTER the spaces, like:
print 'a ', 'b' # prints a b
as opposed to:
print 'a', 'b' # prints a b
Don't do things like string interpolation when they're not needed. It just
makes the code less clear.
- Kef
More information about the Python-list
mailing list