I have an almost trivial (although it was helpful to me) enhancement for
django.utils.datastructures.MergeDict. It basically adds __str__ and
__repr__ methods so that you can see more meaningful output than just
the standard "<custom python object>" string.
Here's my diff:
=== django/utils/datastructures.py
==================================================================
--- django/utils/datastructures.py (revision 15931)
+++ django/utils/datastructures.py (local)
@@ -43,6 +43,13 @@
return True
return False
+ def __str__(self):
+ return str(dict(self.items()))
+
+ def __repr__(self):
+ dictreprs = ', '.join(repr(d) for d in self.dicts)
+ return '%s(%s)' % (self.__class__.__name__, dictreprs)
+
class SortedDict(dict):
"A dictionary that keeps its keys in the order in which they're
inserted."
def __init__(self, data=None):
On another note, I'm using svk to mirror django svn. Is it possible to
submit patches made with svk diff rather than svn diff?
Thanks,
John
John Calixto:
> I have an almost trivial (although it was helpful to me) enhancement for
> django.utils.datastructures.MergeDict. It basically adds __str__ and
> __repr__ methods so that you can see more meaningful output than just
> the standard "<custom python object>" string.
>
> Here's my diff:
>
> === django/utils/datastructures.py
> ==================================================================
> --- django/utils/datastructures.py (revision 15931)
> +++ django/utils/datastructures.py (local)
> @@ -43,6 +43,13 @@
> return True
> return False
>
> + def __str__(self):
> + return str(dict(self.items()))
> +
> + def __repr__(self):
> + dictreprs = ', '.join(repr(d) for d in self.dicts)
> + return '%s(%s)' % (self.__class__.__name__, dictreprs)
> +
Nice!
> On another note, I'm using svk to mirror django svn. Is it possible to
> submit patches made with svk diff rather than svn diff?
Should be no problem.
Michael