Express What, not How.
Vis Mike
visionary25 at _nospam_hotmail.com
Fri Oct 17 15:48:47 EDT 2003
More information about the Python-list mailing list
Fri Oct 17 15:48:47 EDT 2003
- Previous message (by thread): Express What, not How.
- Next message (by thread): Python 2.2 (ActiveState, build 224) and access violations/Dr Watson (long)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Luke Gorrie" <luke at bluetail.com> wrote in message news:lhad81igl6.fsf at dodo.bluetail.com... > ketil+news at ii.uib.no writes: > > > Anonymous functions *can* be more clear than any name. Either because > > they are short and simple, because it is hard to come up with a good > > name, and/or becuase they are ambigous. > > > > Say I want to attach an index to elements of a list. I could write > > > > integers = [1..] > > attach_index ls = zip integers ls > > > > or just > > > > attach_index ls = zip [1..] ls > > If we're arguing to eliminate names that don't say very much, then > > attach_index = zip [1..] I think dynamic scoping within blocks really trims down on duplication and make the code easier to read. For example: employees sort: [ | a b | a date < b date ] A lot of typing for a simple concept: employees sort: [ < data ] I'm not against too much typing to be clear, but rather too much typping that makes the concept unclear. -- Mike > > Whether you want to give an explicit name to the list of integers is > > not given. If the indexed list is local, it is better to use the > > definition directly; I don't want to look up the definition of > > integers (perhaps in a different module) to check whether it is [1..] > > or [0..]. > > And for the exact same reason you might like to just write "zip [1..]" > instead of using a separate "attach_index" function. > > Cheers, > Luke >
- Previous message (by thread): Express What, not How.
- Next message (by thread): Python 2.2 (ActiveState, build 224) and access violations/Dr Watson (long)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list