Re: Internet Data Handling » mailbox

Adam Jensen hanzer at riseup.net
Mon Oct 24 17:46:51 EDT 2016


On 10/22/2016 11:56 PM, Jason Friedman wrote:
>>
>> for message in mailbox.mbox(sys.argv[1]):
>>         if message.has_key("From") and message.has_key("To"):
>>                 addrs = message.get_all("From")
>>                 addrs.extend(message.get_all("To"))
>>                 for addr in addrs:
>>                         addrl = addr.lower()
>>                         if addrl.find(name) > 0:
>>                                 print message
>>                                 break
>> -------------------------------------------------------------
> 
> 
> I usually see
> 
> if addrl.find(name) > 0:
> 
> written as
> 
> if name in addrl:
> 

Yeah, that would be more consistent with the 'for addr in addrs'
construct. But I've never been able to take a serious look at Python, or
develop an understanding and consistent style. The catastrophic
battology[1] present in every book I've encountered is too much of an
obstacle.

[1]: http://grammar.about.com/od/ab/g/battologyterm.htm





More information about the Python-list mailing list