I am used for signs and references, but I need some explanation at this point:
I have this method in my node class:
def createNewNode (article): #new node dictionary newNode = {} # that node newNode ['NAME'] = 'max' Fill out the details for NewNode ['AGE'] = 22 new node ['id'] = 'DC 1234 SH 987' # Graph graph. Add to Added Node (New Node)
Range of newNode
Built-in function is createNewNode ()
. Now this node graph is added to a list of nodes in the class.
The graph class contains this function:
def addNode (self, node): self.nodeList .append (node)
< P> Adds the graph class function addNode ()
node to the list of nodes in the graph class. After calling graph.addNode ()
in the node class, when prevents existing variable of newNode
? No data that was added to the graph class list is now invalid? Does attachment ()
pass a new copy of the object? Can you explain this to me?
(In this example, the graph has a list of nodes and the node is actually a dictionary with the description.)
The name exits from the newNode
, but the object that is mentioned is not deleted. You added a second reference by adding that object to nodeList
attachment
does not make a copy, but it makes a different reference for the same object, with a name goes out of the scope, when this task is finished, but the object only gets garbage when the context of all ends.
No comments:
Post a Comment