From 333581e6fa5435b1336f87971fda689f9798497b Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 29 Aug 2015 12:42:57 +0200 Subject: [PATCH] Added initial value for OrderedLifoDict class --- patacrep/songs/chordpro/ast.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/patacrep/songs/chordpro/ast.py b/patacrep/songs/chordpro/ast.py index 0e68f6dc..8dcea1a7 100644 --- a/patacrep/songs/chordpro/ast.py +++ b/patacrep/songs/chordpro/ast.py @@ -16,9 +16,13 @@ class OrderedLifoDict: - LIFO: the last item is reterned first when iterating. """ - def __init__(self): - self._keys = [] - self._values = {} + def __init__(self, default=None): + if default is None: + self._keys = [] + self._values = {} + else: + self._keys = list(default.keys()) + self._values = default.copy() def values(self): """Same as :meth:`dict.values`.""" @@ -36,7 +40,6 @@ class OrderedLifoDict: def __getitem__(self, key): return self._values[key] - def _indent(string): """Return and indented version of argument.""" return "\n".join([" {}".format(line) for line in string.split('\n')])