Python's simplicity philosophy
Michael T. Babcock
mbabcock at fibrespeed.net
Wed Nov 12 12:01:00 EST 2003
On Wed, Nov 12, 2003 at 08:28:29AM +0000, Robin Becker wrote:
> sequence.sum()
> sequence.reduce(operator.add[,init])
> sequence.filter(func) etc etc
>
> That would make these frighteningly incomprehensible ;)
> concepts seem less like functional programming. Personally I wouldn't
> like that to happen.
I'm hoping you were being sarcastic ... but I get the feeling you aren't.
Why, pray-tell, would you want an OO program to do:
results = [ func(x) for x in sequence ]
... instead of ...
results = sequence.map(func) ??
I can understand if you're writing highly LISP-like Python (see IBM's
articles on functional programming with Python for example). However, I
don't see the 'harm' in offering functional methods to lists/arrays.
Looking at this code I wrote today:
matches = [ get_matches(file) for file in duplicates ]
todelete = [ get_oldest(files) for files in matches ]
... would end up being ...
matches = duplicates.map(get_matches)
todelete = matches.map(get_oldest)
... or better ...
todelete = duplicates.map(get_matches).map(get_oldest)
... and I somewhat like that as I look at it.
--
Michael T. Babcock
CTO, FibreSpeed Ltd. (Hosting, Security, Consultation, Database, etc)
http://www.fibrespeed.net/~mbabcock/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 671 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20031112/e7d39cbf/attachment.sig>
More information about the Python-list
mailing list