[Python-ideas] Allow deleting slice in an OrderedDict

Serhiy Storchaka storchaka at gmail.com
Wed Dec 26 18:54:03 CET 2012


On 26.12.12 18:58, Guido van Rossum wrote:
> Perhaps the desired functionality can be spelled as a method? Would it
> be easy to implement?

This is a pretty trivial method.

     def drop_items(self, n, last=True)
         for i in range(n):
             self.popitem(last)

You can wrap it with "try/except KeyError" or add pre-execution checks 
if you will. I doubt such trivial and not common used method needed to 
be in stdlib.




More information about the Python-ideas mailing list