Reputation: 10142
I have pasted a short portion of my code that is relevant to my question.
I am passing a dict
to the itemSearch
method of my class, but I get a TypeError
def itemsearch(self,*args,**params):
#items = self.api.item_search('Books', Publisher="O'Reilly", Author="James Shore",Year="2014",limit=10)
print args
print params
itemSearch=self.api.item_search(*args,**params)
print [item.ASIN for items in itemSearch.Items.Item]
self.listASIN=[(item.Title,item.ASIN) for items in itemSearch.Items.Item]
amazonsearch=AmazonLookup()
params={'SearchIndex':'Electronics','Condition':'New','Keywords':'Macbook pro 13 retina','MinimumPrice':'600',
'MaximumPrice':'2000','Sort':'-price'}
print params
amazonsearch.itemsearch(**params)
I get TypeError: item_search() takes at least 2 arguments (1 given)
Upvotes: 0
Views: 240
Reputation: 387915
The problem is in this line:
itemSearch = self.api.item_search(*args, **params)
Apparently, the item_search
function requires a positional argument first. Positional arguments are filled from args
but args
is an empty list as you call the itemsearch
function only with a unpacked dictionary:
amazonsearch.itemsearch(**params)
So you need to provide at least that first parameter too (like in your commented-out example: 'Books'
).
Upvotes: 2