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 pitrou
Recipients pitrou, rhettinger
Date 2013-02-01.16:32:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359736323.45.0.953309245292.issue17100@psf.upfronthosting.co.za>
In-reply-to
Content
It can be useful to rotate an OrderedDict (for example when managing a circular playlist). I haven't found any efficient way to do so from user code, without poking at the internals.

Actually, I envision three methods:

 OrderedDict.rotate(self, n):

   rotate n steps to the right (similarly to deque.rotate())

 OrderedDict.rotate_at(self, key):

   rotate so that the given key ends up in first position

 OrderedDict.rotate_after(self, key):

   rotate so that the given key ends up in last position

(rotate_at, rotate_after could be merged in a single method with a "last" argument, if deemed more elegant)

Note: another solution to the playlist problem would be to have insert_after() and insert_before() methods.
History
Date User Action Args
2013-02-01 16:32:03pitrousetrecipients: + pitrou, rhettinger
2013-02-01 16:32:03pitrousetmessageid: <1359736323.45.0.953309245292.issue17100@psf.upfronthosting.co.za>
2013-02-01 16:32:03pitroulinkissue17100 messages
2013-02-01 16:32:02pitroucreate