Russell E. Owen wrote: > I'd like to have the get method available for lists and tuples. (I > figured this must have been discussed before but can't recall it and > didn't turn anything up on google). > > It's obviously not a use-all-the-time method (or it'd already be there), > but I find myself wanting it often enough to justify it in my own mind > (and curse this omission, relative to dict). > > Basically I run into it when parsing data of variable length (where the > extra elements have some obvious default value), including config files, > sys.argv (for simple command scripts), that sort of thing. > > Yes a 4-liner does the job, but "get" would be a much clearer way to > write it.
A 4-liner? x = (list[i:i+1] or (default,))[0] is just one line ;) Honestly, often enough you can work around with slices in one or the other way. > Anyway, I'm just testing the waters. If it's not heresy then I'd like to > do what I can to make it happen. IMO there's almost no chance this can go into 2.5. Georg _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com