how to prevent the "extended call syntax" (*) from expanding a stringinto a list of characters

Discussion in 'Python' started by fulv, Jul 22, 2010.

  1. fulv

    fulv Guest

    I get the following error:

    File "<stdin>", line 1, in ?
    File "/Users/fulvio/plone/seiu_new/buildout/eggs/z3c.saconfig-0.11-
    py2.4.egg/z3c/saconfig/utility.py", line 164, in __call__
    _ENGINES[self._key] = engine = sqlalchemy.create_engine(
    File "/Users/fulvio/plone/seiu_new/buildout/eggs/SQLAlchemy-0.6.3-
    py2.4.egg/sqlalchemy/engine/__init__.py", line 244, in create_engine
    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)


    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. It seems
    to me that create_engine is interpreting that as a list of 150
    characters.

    Any suggestions, on what I'm doing wrong?

    Thanks!
    Fulvio
     
    fulv, Jul 22, 2010
    #1
    1. Advertising

  2. fulv

    James Mills Guest

    Re: how to prevent the "extended call syntax" (*) from expanding astring into a list of characters

    On Thu, Jul 22, 2010 at 4:26 PM, fulv <> wrote:
    >  args = (connection_string)


    Replace this with:

    args = (connection_string,)

    NOTE: The trailing , (comma) indicating that this _is_ a tuple.

    cheers
    James

    --
    -- James Mills
    --
    -- "Problems are solved by method"
     
    James Mills, Jul 22, 2010
    #2
    1. Advertising

  3. Re: how to prevent the "extended call syntax" (*) from expanding astring into a list of characters

    On Wed, 21 Jul 2010 23:26:35 -0700 (PDT), fulv <>
    declaimed the following in gmane.comp.python.general:

    > args = (connection_string)


    args = (connection_string,)

    > kwargs = {'echo' : True, 'encoding' : 'cp1252'}
    > return args, kwargs
    >
    > In other words, args is a list containing just one string. It seems
    > to me that create_engine is interpreting that as a list of 150
    > characters.
    >
    > Any suggestions, on what I'm doing wrong?
    >

    Parens don't make a tuple, the comma does...
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Jul 22, 2010
    #3
  4. fulv

    fulv Guest

    Re: how to prevent the "extended call syntax" (*) from expanding astring into a list of characters

    Thank you all! Really appreciate the quick help!
     
    fulv, Jul 22, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dmitri Zakharov
    Replies:
    2
    Views:
    6,561
    Dmitry Roslyakov
    Jun 11, 2004
  2. Bill
    Replies:
    1
    Views:
    436
    Johannes Koch
    Apr 28, 2004
  3. Edward K. Ream

    When was extended call syntax introduced?

    Edward K. Ream, Dec 20, 2004, in forum: Python
    Replies:
    4
    Views:
    1,453
    Edward K. Ream
    Dec 22, 2004
  4. Antonio Ooi
    Replies:
    2
    Views:
    239
    Steven Burn
    May 15, 2004
  5. Neil Shadrach
    Replies:
    2
    Views:
    421
    Neil Shadrach
    Oct 28, 2003
Loading...

Share This Page