From 301a600923271687bf15388734c38eb936a603a3 Mon Sep 17 00:00:00 2001 From: Alexandre Morignot Date: Mon, 24 Nov 2014 20:21:24 +0100 Subject: [PATCH] Account() constructor does not take an id --- docs/source/guides/module.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/guides/module.rst b/docs/source/guides/module.rst index 3ed03ac3..85d30729 100644 --- a/docs/source/guides/module.rst +++ b/docs/source/guides/module.rst @@ -368,8 +368,8 @@ For example:: class ListPage(LoggedPage, HTMLPage): def get_accounts(self): for el in self.doc.xpath('//ul[@id="list"]/li'): - id = el.attrib['id'] - account = Account(id) + account = Account() + account.id = el.attrib['id'] account.label = el.xpath('./td[@class="name"]').text account.balance = Decimal(el.xpath('./td[@class="balance"]').text) yield account @@ -382,7 +382,8 @@ An alternative with ``cssselect``:: def get_accounts(self): for el in self.document.getroot().cssselect('ul#list li'): id = el.attrib['id'] - account = Account(id) + account = Account() + account.id = el.attrib['id'] account.label = el.cssselect('td.name').text account.balance = Decimal(el.cssselect('td.balance').text) yield account