summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-01-08 19:02:26 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-01-08 19:02:26 +0000
commit37c762622cf4ea91d34a591b5f71771db27bb5cb (patch)
tree2ce5727bbf7fa43b8fbcac59e3f1cf5609fff767 /lib/sqlalchemy/util.py
parent23b744807599d01e6652a83d82e29da95695c814 (diff)
downloadsqlalchemy-37c762622cf4ea91d34a591b5f71771db27bb5cb.tar.gz
added some __repr__ functionality
Diffstat (limited to 'lib/sqlalchemy/util.py')
-rw-r--r--lib/sqlalchemy/util.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py
index b922a8246..7f417ba7e 100644
--- a/lib/sqlalchemy/util.py
+++ b/lib/sqlalchemy/util.py
@@ -4,7 +4,7 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-__all__ = ['OrderedProperties', 'OrderedDict']
+__all__ = ['OrderedProperties', 'OrderedDict', 'generic_repr', 'HashSet']
import thread, weakref, UserList,string, inspect
def to_list(x):
@@ -14,6 +14,10 @@ def to_list(x):
return [x]
else:
return x
+
+def generic_repr(obj, exclude=None):
+ L = ['%s=%s' % (a, repr(getattr(obj, a))) for a in dir(obj) if not callable(getattr(obj, a)) and not a.startswith('_') and (exclude is None or not exclude.has_key(a))]
+ return '%s(%s)' % (obj.__class__.__name__, ','.join(L))
class OrderedProperties(object):
"""an object that maintains the order in which attributes are set upon it.