[New-bugs-announce] [issue17022] Inline assignation uses the newly created object

Gabriel Nistor report at bugs.python.org
Thu Jan 24 10:30:55 CET 2013


New submission from Gabriel Nistor:

I am using Lubuntu x64 version and python 3.2.3
I have a tree search method:

node = self
while xpaths:
    xpath = xpaths.popleft()
    for path, child in node.childrens.items():
        if path == xpath:
            node = child
            break
    else:
        node = node.childrens[xpath] = Node(xpath)
return node

This fails because the node is created and then the node.childrens[xpath] assignation is done on the new created node rather then the old node, I needed to do something like:
        child = node.childrens[xpath] = Node(xpath)
        node = child
to have the proper behavior.

----------
components: Interpreter Core
messages: 180518
nosy: chupym
priority: normal
severity: normal
status: open
title: Inline assignation uses the newly created object
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17022>
_______________________________________


More information about the New-bugs-announce mailing list