[CentralOH] 2013-04-11 道場

Kurtis Mullins kurtis.mullins at gmail.com
Fri Apr 12 22:02:54 CEST 2013


Also, I recently bought a Das Keyboard Pro Model S and I love it!


On Fri, Apr 12, 2013 at 4:01 PM, Kurtis Mullins <kurtis.mullins at gmail.com>wrote:

> On Fri, Apr 12, 2013 at 10:31 AM, Eric Floehr <eric at intellovations.com>wrote:
>
>>
>>
>> And if you are using Python 2.5 or higher, this is "best", as it closes
>> the file always, even on an exception:
>>
>> with open('foo', 'rU') as f:
>>     for line in f:
>>         # Do whatever with line or pass
>>
>
> That's actually what I use as well; however, I still have to check for
> blank lines. I assumed that's what jep was alluding to.
>
> For example (out of a script I recently wrote):
>
> with open(negation_lexicon_file_name, 'rb') as negation_file:
>     for line in negation_file:
>         phrase = line.strip().lower()
>         if phrase:
>             negation_lexicon['lexemes'].append(phrase)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/centraloh/attachments/20130412/ce8f132b/attachment.html>


More information about the CentralOH mailing list