Fisticuffs

Jun. 14th, 2006 06:43 pm
aparrish: (Default)
So I've taken up Python. I'm a Perl programmer—a prototypical Perl programmer, in that my professional career has, in the main, consisted of writing CGI scripts and maintaining other people's CGI scripts. Forays into the actual writing of software as opposed to slapping some crap together or poking sticks at other people's crap have been few and far between. So I'm still learning. This is all preliminary.

I just wanted to write for a while about what it's like to code in Python after all these years of Perl.

Perlish things I'm used to that Python won't give me:
  • Anonymous subroutines. I know about lambda, but it isn't the same. There's something very intuitive about the way people use anonymous subroutines in Perl, especially for event-driven stuff.
  • Sigils. I like sigils for two reasons. They make it easy to pick out variables from the rest of the syntax. (They're like articles in this way, or word endings in Esperanto.) They also help prevent naming conflicts with reserved words or subroutines defined in modules. Oh, and it's easier to read when you want to interpolate them into strings!
  • $_. I don't like having to name my temporary loop variables! Writing stuff like print foreach @foo is awesome, much more so than for x in foo: print x.
  • Chapter 24 of Programming Perl ("Common Practices") basically taught me everyting I know about writing good Perl. I can't find anything similar for Python. Is there something out there that has examples of good, idiomatic, fluent Python in a concise, easy-to-read format?

Python things that make me want to keep coding in Python:
  • Sane scoping (for the most part). I don't have to type my all over the place!
  • Internal data types are objects. I feel like this makes for more intuitive code. And I like that I can make my own objects behave like built-ins without messing around with crazy tie stuff.
  • The % operator! Clever.
  • List comprehensions. Sorta. You can do the same thing in Perl with map/grep, but it's not quite as readable or convenient.

On the personality front, Larry Wall looks like Richard Kiel, but Guido van Rossum looks like Robert Pollard. So it's kind of a draw.

March 2016

S M T W T F S
  12345
6789101112
13141516171819
20212223 242526
2728293031  

Syndicate

RSS Atom

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 14th, 2025 10:01 am
Powered by Dreamwidth Studios