From: Ben Finney on
fulv <fulviocasali(a)gmail.com> writes:

> return strategy.create(*args, **kwargs)
> TypeError: create() takes exactly 2 non-keyword arguments (150 given)
>
> Basically, args and kwargs come as the return values from my
> overridden function configuration():
>
> args, kw = self.configuration()
> _ENGINES[self._key] = engine =
> sqlalchemy.create_engine(
> *args, **kw)

(As a side note: Please use a mail client that won't wrap your lines
incorrectly like the above. That might mean not using Google Mail.)

> This is what I'm returning from configuration():
>
> args = (connection_string)
> kwargs = {'echo' : True, 'encoding' : 'cp1252'}
> return args, kwargs
>
> In other words, args is a list containing just one string.

No, it isn't. The syntax you've used merely puts parentheses around the
object 'connection_string'; parentheses don't make a list. So, when you
use the argument unpacking syntax, the string gets unpacked into its
component characters, as you noticed.

You might have meant “a tuple containing just one string”. But
parentheses don't make a tuple either.

To make a tuple, use commas. You may put parentheses around the tuple to
distinguish it from surrounding syntax, and because commas are used in
various other places, sometimes you need to. But never forget that it's
the commas that make the tuple, not the parentheses.

args = (connection_string,)
kwargs = {'echo': True, 'encoding': 'cp1252'}
return args, kwargs

I hope that helps.

--
\ “It is far better to grasp the universe as it really is than to |
`\ persist in delusion, however satisfying and reassuring.” —Carl |
_o__) Sagan |
Ben Finney