Is Python growing?

Paul Rubin phr-n2002b at NOSPAMnightsong.com
Thu Jun 27 23:10:19 EDT 2002


Matthew Dixon Cowles <matt at mondoinfo.com> writes:
> On the other hand, some features make Python much easier to use and
> read. A while ago, I replaced:
> 
> def lengthOfLongestStr(list):
>   l=len(list[0])
>   for count in range(1,len(list)):
>     if len(list[count])>l:
>       l=len(list[count])
>   return l
> 
> with
> 
> def lengthOfLongestStr(myList):
>   return max([len(s) for s in myList])
> 
> To my eye, the second one is much easier to read. 

Well, you could have said

    def lengthOfLongestStr(myList):
      return max (map (len, myList))

without needing any new features added.



More information about the Python-list mailing list