paul rubin <p...@users.sourceforge.net> added the comment: David, I'm not on that mailing list so hadn't seen the earlier discussion. I sympathasize with Raymond's YAGNI argument because I'm comfortable with reduce(max,seq,0); but then I remember there was once a movement to remove the "reduce" function from builtins, which would have broken that idiom. I also understand that not everyone is comfortable with that style. I recently had to hand over some code to another programmer where I had used that idiom, and in the course of adding comments to the code in preparation for the handover, I found myself writing quite a few words about why I'd used "reduce" that way, so I figured that "explicit is better than implicit" suggests adding default or initial args to the max function, just like "reduce" already has (I figure that max on a sequence is a special case of reduce).
My proposed python implementation: def mymax(*args, **kwargs): if len(args) > 1: return max(*args) if len(args) == 0: raise TypeError, "mymax needs at least one positional arg" if 'initial' in kwargs: return reduce(max,args[0],kwargs['initial']) return reduce(max,args[0]) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7153> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com