Complex compound expressions

Jeremy Fincher tweedgeezer at hotmail.com
Sat Aug 17 03:55:48 EDT 2002


Erik Max Francis <max at alcyone.com> wrote in message news:<3D5D7F2B.C42D37DC at alcyone.com>...
> Why do you think there is a way to use the shorthand you want?  It is
> actually not all that common in programming languages (though some do
> have it).  There _is_ a particular shorthand you can use here, since
> string.letters and string.digits are both strings:  You can concatenate
> them with the + operator and then test against that:
> 
> 	if character in (string.letters + string.digits):
> 	    ...
> 
> Remember, though:  Brevity is not in and of itself a good thing. 
> Clarity should almost always win out over brevity.

Also note that this approach is less efficient than the "if character
in string.letters or character in string.digits" approach, since it
has to create a string object every time it tests.

Jeremy



More information about the Python-list mailing list