diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-29 16:31:31 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-29 16:31:31 +0000 |
commit | 6a1970e978bea1fc4a95b17f69ce0af65d424806 (patch) | |
tree | 2dc5c105fc6d551012714dac4cafe7de08b5ba96 /lib/sqlalchemy/util.py | |
parent | 4fef0a23a175e64475955a67dd557347cc99f19a (diff) | |
download | sqlalchemy-6a1970e978bea1fc4a95b17f69ce0af65d424806.tar.gz |
turned starargs conversion to a decorator, per jek's advice. select().order_by()/group_by() already take *args.
Diffstat (limited to 'lib/sqlalchemy/util.py')
-rw-r--r-- | lib/sqlalchemy/util.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index 6919d1557..26b6dbe9a 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -188,15 +188,17 @@ def to_list(x, default=None): else: return x -def starargs_as_list(*args): - """interpret the given *args as either a list of *args, - or detect if it's a single list and return that. +def array_as_starargs_decorator(func): + """Interpret a single positional array argument as + *args for the decorated method. """ - if len(args) == 1: - return to_list(args[0], []) - else: - return list(args) + def starargs_as_list(self, *args, **kwargs): + if len(args) == 1: + return func(self, *to_list(args[0], []), **kwargs) + else: + return func(self, *args, **kwargs) + return starargs_as_list def to_set(x): if x is None: |