Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Keyword argument 'from'; invalid syntax

2 views
Skip to first unread message

Kai Kuehne

unread,
Jul 25, 2007, 9:33:20 PM7/25/07
to pytho...@python.org
Hi list!
I'm using pygmalion (magnolia api access lib) and want to
use the following method that it is offering:

magnolia.bookmarks_find(person='user', from=some_datetime)

As you may noticed, from is a keyword argument and so I
get the following error message from python:

File "<ipython console>", line 1
magnolia.bookmarks_find(person='user', from=some_datetime)
^
<type 'exceptions.SyntaxError'>: invalid syntax

I have tried to prepare a dict and then passing it to the
method afterwards:
>>> d = {'person': 'user', 'from': vorgestern}
>>> magnolia.bookmarks_find(d)
<type 'exceptions.TypeError'>: bookmarks_find() takes exactly 1
argument (2 given)

I'm out of ideas so help is greatly appreciated!
Thanks
Kai

Paul Rubin

unread,
Jul 25, 2007, 9:44:37 PM7/25/07
to
"Kai Kuehne" <kai.k...@gmail.com> writes:
> >>> d = {'person': 'user', 'from': vorgestern}
> >>> magnolia.bookmarks_find(d)
> <type 'exceptions.TypeError'>: bookmarks_find() takes exactly 1
> argument (2 given)
>
> I'm out of ideas so help is greatly appreciated!

Try
magnolia.bookmarks_find(**d)

Steven D'Aprano

unread,
Jul 25, 2007, 10:08:40 PM7/25/07
to
On Thu, 26 Jul 2007 03:33:20 +0200, Kai Kuehne wrote:

> I have tried to prepare a dict and then passing it to the
> method afterwards:
>>>> d = {'person': 'user', 'from': vorgestern}
>>>> magnolia.bookmarks_find(d)
> <type 'exceptions.TypeError'>: bookmarks_find() takes exactly 1
> argument (2 given)
>
> I'm out of ideas so help is greatly appreciated!

Try this:

magnolia.bookmarks_find(**d)

although I suspect that will probably raise an exception as well. Judging
by the error message, it looks like bookmarks_find() takes only a single
argument, which I imagine would be the "self" instance automatically
provided at runtime.

--
Steven.

Kai Kuehne

unread,
Jul 25, 2007, 10:07:37 PM7/25/07
to pytho...@python.org
Hi Steven,

On 7/26/07, Steven D'Aprano <st...@remove.this.cybersource.com.au> wrote:
> On Thu, 26 Jul 2007 03:33:20 +0200, Kai Kuehne wrote:

> Try this:
>
> magnolia.bookmarks_find(**d)

This works perfectly, thank you guys.
Kai

Stargaming

unread,
Jul 26, 2007, 1:50:00 AM7/26/07
to

Could be bookmarks_find(person, **other), unpacking other manually.

0 new messages