Popular conceit about learning programming languages
Kenny Tilton
ktilton at nyc.rr.com
Mon Nov 25 16:00:02 EST 2002
Robin Munn wrote:
> Kenny Tilton <ktilton at nyc.rr.com> wrote:
>>What is it about Pythonthink that is different from Otherlangthink?
>>
> I found myself writing for loops that weren't necessary, e.g.:
>
> # Thinking in C, translating into Python
> new_list = []
> for item in old_list:
> if (item % 2): # Keep only the odd numbers
> new_list.append(item)
>
> # Thinking in Python
> new_list = filter(lambda x: x%2, old_list)
Good example, and I went thru the same with CL. I do not usually read
language references just to read them, but eventually I broke down and
looked at the lonnnnng list of functions to see if I was missing stuff.
I definitely reinvented the wheel many times with CL, hopefully that
will not happen so much with Python cuz Norvig raves about Python so
I'll be /expecting/ to find CLisms in Python.
meanwhile, i feel like such an ass, even tho the hack i am translating
intervenes at the level of attr access and I have been pouring over the
doc on __getattr__ and __setattr__, damn!, I never picked up that
getattr and setattr were the implementing backdoors! hours wasted!! :)
--
kenny tilton
clinisys, inc
---------------------------------------------------------------
""Well, I've wrestled with reality for thirty-five years, Doctor,
and I'm happy to state I finally won out over it.""
Elwood P. Dowd
More information about the Python-list
mailing list