Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jplindstrom (594)

  (email not shown publicly)

Journal of jplindstrom (594)

Tuesday April 24, 2007
10:08 AM

Python list comprehension

[ #33090 ]

List comprehension in Python sounds cool and all, but it seems like it's "just" syntax for map and grep.

Or am I missing something?

(If nothing else, it's good to know what "list comprehension" is so you have at least an inkling of a clue when you encounter the phrase. The same goes for words like "tuple" (immutable list, right?).)

Actually even if it's just map and grep in sheep's clothing, syntax is rarely "just" anything.

A lot of times I've found that seemingly small things make a lot of difference usability-wise, and those small things make a huge actual difference in how you use or percieve something. There's a threshold value of resistance/friction to using anything, and when the friction is minute enough, that's when interesting things happen.

An example is how I use command completion.

Another is the way regular expressions are integrated into the Perl syntax. Looking at other languages where objects need to be created left and right to do the most simple things boggles the code reading mind.

Or the recent blog topic "we-can-fake-closures-with-objects-and-pretend-it's-the-same-thing".

So, is list comprehension different enough to make a difference?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.