{"id":68,"date":"2012-11-06T20:26:17","date_gmt":"2012-11-07T04:26:17","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=68"},"modified":"2012-11-06T20:26:17","modified_gmt":"2012-11-07T04:26:17","slug":"python-nodes-in-a-list","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/python-nodes-in-a-list\/","title":{"rendered":"Python Nodes In A List"},"content":{"rendered":"
Quick and simple Python list with node insert capabilty.<\/p>\n
\r\nclass Node:\r\n def __init__(self,value):\r\n self.data = value\r\n self.next = 0\r\n\r\nclass List:\r\n def __init__(self):\r\n self.firstNode = Node(0)\r\n def __ShowNodeData(self,aNode):\r\n if aNode.next != 0:\r\n print aNode.data\r\n self.__ShowNodeData(aNode.next)\r\n def Dump(self):\r\n self.__ShowNodeData(self.firstNode)\r\n def InsertAfter(self,aNode,aNewNode):\r\n aNewNode.next = aNode.next\r\n aNode.next = aNewNode\r\n def InsertBeginning(self,aNewNode):\r\n aNewNode.next = self.firstNode\r\n self.firstNode = aNewNode \r\n\r\nnodeA = Node(\"A\")\r\nnodeB = Node(\"B\")\r\nnodeC = Node(\"C\")\r\nnodeD = Node(\"D\")\r\n\r\naList = List()\r\n\r\naList.InsertBeginning(nodeB)\r\naList.InsertAfter(nodeB,nodeD)\r\naList.InsertAfter(nodeD,nodeC)\r\naList.InsertAfter(nodeC,nodeA)\r\n \r\naList.Dump()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"Quick and simple Python list with node insert capabilty. class Node: def __init__(self,value): self.data = value self.next = 0 class<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}