How to detect the last element in a for loop
Roy Smith
roy at panix.com
Sun Jul 28 11:21:17 EDT 2002
Tom Verbeure <tom.verbeure at verizon.no.sp.am.net> wrote:
> say, 10 lines of code. Too much to duplicate it outside the loop, not
> enough for a separate function...
Why is 10 lines of code not enough for a separate function? I use
functions to group code into conceptual blocks that can be thought about
and understood as a unit. Sometimes that block is 100 lines of code,
sometimes it's 3 or 4 lines. I've even written one-line functions.
Whatever makes sense to factor out as an atomic unit. Line count has
little to do with it.
I'm not quite as rabid about it as the XP'er are with "Refactor
Mercilessly", but (like so much with XP) the basic idea has merit if you
don't try to be too extreme about it :-)
More information about the Python-list
mailing list