A
anon
I'm aware that you can assign a value to an attribute in all class
instances by assigning to <Class>.<attribute>, however, my case is
slightly different and bizarre.
In module node:
top, left, mid, right = range(4)
class Node:
def __init__(self, ntype = None, function = None, symbol = None,
meta = None, adjacent = [None, None, None, None]):
self.type = ntype
self.function = function
self.symbol = symbol
self.meta = meta
self.adjacent = adjacent
Here's the wierd thing, in another module I have:
node.adjacent
instances by assigning to <Class>.<attribute>, however, my case is
slightly different and bizarre.
In module node:
top, left, mid, right = range(4)
class Node:
def __init__(self, ntype = None, function = None, symbol = None,
meta = None, adjacent = [None, None, None, None]):
self.type = ntype
self.function = function
self.symbol = symbol
self.meta = meta
self.adjacent = adjacent
Here's the wierd thing, in another module I have:
node.adjacent
= y
where node is an instance of the Node class. This statement assigns
all Node instances the value y to attribute adjacent
where node is an instance of the Node class. This statement assigns
all Node instances the value y to attribute adjacent
. This seems
very wrong, unless python resolves names in a case-insensitive way.
When I try the alternate:
node.adjacent = [None, y, None, None]
I get the behavior I expect (ie. only the instsance node gets its
attribute set)
Can anyone shed any light on this?
Thanks.
--Greg
very wrong, unless python resolves names in a case-insensitive way.
When I try the alternate:
node.adjacent = [None, y, None, None]
I get the behavior I expect (ie. only the instsance node gets its
attribute set)
Can anyone shed any light on this?
Thanks.
--Greg