jweinst1
7/22/2015 - 6:20 PM

Linked Nodes.py

Linked Nodes.py

class Node (object):
	def __init__(self, cargo=0, next=0):
		self.cargo, self.next = cargo, next
class NodeList (list):
	
	def __init__(self, head):
		self.append(head)
	def deeplen(self):
		strlst = list(str(self))
		numlist = [s for s in strlst if s != '[' and s != ']' and s != ' ' and s != ',']
		return len([int(x) for x in numlist])
	def addtail(self, tail):
		value = [tail]
		command, length, count = 'self', self.deeplen(), 0
		while count < length-1:
			command += str([1])
			count += 1
		command += '.append(%s)' %(value)
		eval(command)
		return self