From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YspwG-0000ke-Bt for qemu-devel@nongnu.org; Thu, 14 May 2015 06:00:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YspwB-0005e5-Ar for qemu-devel@nongnu.org; Thu, 14 May 2015 06:00:24 -0400 Sender: Paolo Bonzini Message-ID: <55547221.4030109@redhat.com> Date: Thu, 14 May 2015 12:00:01 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1431519294-8873-1-git-send-email-M.Cerveny@computer.org> <1431519294-8873-3-git-send-email-M.Cerveny@computer.org> In-Reply-To: <1431519294-8873-3-git-send-email-M.Cerveny@computer.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] scripts: qom-tree: add support of path as argument List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Martin Cerveny , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org On 13/05/2015 14:14, Martin Cerveny wrote: > for item in items: > if item['type'].startswith('child<'): > - list_node(path + '/' + item['name']) > + list_node((path if (path != '/') else '') + '/' + item['name']) I'm not sure which Python version introduced if...else. The more traditional idiom would be path != '/' and path or '' Can you use it, and move the expression out of the 'for item in items' loop into a variable? Paolo