Iterating over a dictionary's sorted keys

Robert Roy rjroy at takingcontrol.com
Fri May 26 13:41:04 EDT 2000


On Thu, 25 May 2000 22:03:19 -0600, Ivan Van Laningham
<ivanlan at home.com> wrote:

>Hi All--
>
>Alan Daniels wrote:
>> 
>> On 25 May 2000 08:56:38 GMT, Remco Gerlich
>> <scarblac-spamtrap at pino.selwerd.nl> wrote:
>> 
>> [snip...]
>> >Why the problem with multiple lines and an extra variable here and there?
>> 
>> Yes, but the short version reminds me very much of one of my favorite
>> python idioms:
>> 
>>     lines = open("some_file", "rt").readlines()
>> 
>
>If you don't want the newlines, you can do this:
>
>alist=open("some_file","rt").read().split()

might not work too well with text like:

this is a test
to see what will happen
if I do a split on this file
I think I will get a lot more
elements
than I bargained for


Bob

>
>in 1.6.
>
><at-least-you-should-be-able-to>-ly y'rs,
>Ivan
>----------------------------------------------
>Ivan Van Laningham
>Axent Technologies, Inc.
>http://www.pauahtun.org/
>http://www.foretec.com/python/workshops/1998-11/proceedings.html
>Army Signal Corps:  Cu Chi, Class of '70
>Author:  Teach Yourself Python in 24 Hours
>




More information about the Python-list mailing list