File traversing

Nibin V M nibinvm at gmail.com
Tue Apr 17 07:14:12 EDT 2012


wow...thanks Karl :)

On Tue, Apr 17, 2012 at 2:20 AM, Karl Knechtel <zahlman at gmail.com> wrote:

>
>
> On Sun, Apr 15, 2012 at 5:51 AM, Chris Angelico <rosuav at gmail.com> wrote:
>
>>
>> (You may also want to consider using the 'with' statement to guarantee
>> a timely closing of the file. Outside the scope of this mail though.)
>>
>> I think this list is just to collect unique entries, yes? If so, a set
>> may be more to your liking. Check out:
>> http://docs.python.org/py3k/library/stdtypes.html#set
>>
>>  <http://mail.python.org/mailman/listinfo/python-list>
>>
>
> In cases like this I like to just show the final code after making all the
> changes, and let the student ask questions :)
>
> with open('/bah') as res_own_file:
>     all_res = set(line.strip().replace(' ', '').split(':')[1] for line in
> res_own_file if ':' in line)
>
> --
> ~Zahlman {:>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>


-- 
Regards....

Nibin.

http://TechsWare.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120417/00cf4456/attachment.html>


More information about the Python-list mailing list