This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients gruszczy, rhettinger
Date 2011-04-19.20:00:50
SpamBayes Score 1.7208457e-14
Marked as misclassified No
Message-id <1303243252.32.0.594010696101.issue11881@psf.upfronthosting.co.za>
In-reply-to
Content
> operator.getitem could be extended to accept default value

That would be relatively harmless.  And because it isn't type specific to lists, it would be applicable to other types that might better use cases than lists do.

If you want to pursue this, please change the name of this tracker item and re-open it.

Do spend some time thinking about whether it is good language design.  Is "getitem(s, i, dft)" better than "s[i] if i < len(s) else dft" or list unpacking, etc.?  Various meanings of better include 1) the preferred way to do it, 2) a faster way to do it, 3) surrounding code reads significantly better using the new construct, and 4) it's worth taking the time to learn and remember it.  By adding this to the language, you're telling people that this is the RightThingToDo(tm).  

Programming this is easy -- the hard part is knowing whether it is worthwhile (a question on StackOverflow is not sufficient motivation).  You might also want to grep lots of real world code to see if there would be actual benefits to real code or whether it will end-up being cruft that we put in because it was easy and cute.  Python has had 20+ years of development without needing this, so it's worth really thinking about it before going ahead.
History
Date User Action Args
2011-04-19 20:00:52rhettingersetrecipients: + rhettinger, gruszczy
2011-04-19 20:00:52rhettingersetmessageid: <1303243252.32.0.594010696101.issue11881@psf.upfronthosting.co.za>
2011-04-19 20:00:51rhettingerlinkissue11881 messages
2011-04-19 20:00:50rhettingercreate