language design question

Gregory Guthrie guthrie at mum.edu
Sun Jul 9 13:19:13 EDT 2006


I am comparing Python to a few other scripting languages, and used a simple 
anagrams program as a sample.

I was surprised ast a few python features that did not work as I would 
expect/wish; which caused less compact/expressive program styles that I 
wanted - reverting to a FORTRAN like series of assignments.

For example,
   - why is len() not a member function of strings? Instead one says len(w).

  - Why doesn't sort() return a value?

    This would allow things like:
        key = '',join( list(word.lower().strip()).sort() )
    instead:
        key = ...
        key.sort()
        key = ...

   - Another feature I assumed but it failed, is a nice default for 
dictionaries, and more += like operations;
   For example: to acculumate words in a dictionary -
        dict[key] += [word]

     Instead of:
        mark[key] = mark.get(key,[]) + [word]

The former seems very intuitive, and clearer.
I am a bit used to the compactness and convenient defaults of Perl, which 
would do this:
   my $key = join '', sort(split(//, lc($word)));
    push @{$anagrams{$key}}, $word

I am curious why these "obvious" conveniences are not present.  :-)
Thansk for any context or insight.

Best,
Gregory

Perl is great, and 



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----



More information about the Python-list mailing list