Suggest: .get() method on lists.

Gerrit Holl gerrit.holl at pobox.com
Tue Jan 18 15:22:29 EST 2000


Hello,

What about having a get() method on lists?
I thought it would be useful, for example, for sys.argv. At the moment,
I have this code:

file = sys.stdin
if len(sys.argv) > 1:
    file = sys.argv[1]

But this, would be much easier to read:
file = sys.argv.get(1, sys.stdin)

Of course, it's also possible to use multiple inheritance on
UserList and UserDict creating a DictionairyList for sys.argv,
because it's the only place I can think of such a feature would
be a Good Thing (TM).

it's-funny-to-browse-the-old-archives-and-see-who-already-was-here-ly y'rs - ger

-- 
Please correct any bad English you encounter in my email message!
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK-----




More information about the Python-list mailing list