qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/2] scripts: qom-tree: add support of path as a


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 2/2] scripts: qom-tree: add support of path as argument
Date: Thu, 14 May 2015 12:00:01 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0


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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]