B
Brent W. Hughes
Warning: Newbie at work!
I was planning to write some code something like this:
class CTree:
LEAFSIZE = 4
LeafNode = [None] * LEAFSIZE
KEY,DATA,LEFT,RIGHT = range(LEAFSIZE)
#---------------------------------------------------
def Add(self,Node,SubTree):
Key1 = Node[KEY]
....
But then I realized that the last line (and many more similar lines)
would probably need to be writen thusly:
Key1 = Node[CTree.KEY]
I find this a little ugly, not to mention more typing. I suppose
I could move these lines:
LEAFSIZE = 4
KEY,DATA,LEFT,RIGHT = range(LEAFSIZE)
out of the class and make them global, but this kind of runs
against the grain.
Is there another way to deal with "constants"?
I was planning to write some code something like this:
class CTree:
LEAFSIZE = 4
LeafNode = [None] * LEAFSIZE
KEY,DATA,LEFT,RIGHT = range(LEAFSIZE)
#---------------------------------------------------
def Add(self,Node,SubTree):
Key1 = Node[KEY]
....
But then I realized that the last line (and many more similar lines)
would probably need to be writen thusly:
Key1 = Node[CTree.KEY]
I find this a little ugly, not to mention more typing. I suppose
I could move these lines:
LEAFSIZE = 4
KEY,DATA,LEFT,RIGHT = range(LEAFSIZE)
out of the class and make them global, but this kind of runs
against the grain.
Is there another way to deal with "constants"?