common practice for creating utility functions?

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue May 16 01:50:26 CEST 2006


John Salerno a écrit :
> John Salerno wrote:
> 
>> John Salerno wrote:
>>
>>> Just a quickie for today
>>
>>
>> Another quick one I'll combine in this thread: How can I create two 
>> separate conditions in a for loop?
>>
>> Such as this, which doesn't seem to work beyond string.punctuation:
>>
>> for char in string.punctuation or string.whitespace:
> 
> 
> I tried this:
> 
> punc_space = string.punctuation + string.whitespace
> for char in punc_space:

Or if you want to save memory (which is not a problem in this example) :

import itertools
for char in itertools.chain(string.punctuation, string.whitespace):
   ...



More information about the Python-list mailing list