by r3dey3 · 9y ago · 0 comments
Then there's the bug that you can't delete the first node in a list.
And then there's the fact that double linked list doesn't have a tail pointer.
And then there's the fact that they use the same node class in double linked as single, but the previous member is set by the list, but isn't always set so you might get an exception some times.
Then there's the fact that search is only implemented for single linked .. Oh and its RECURSIVE!
It'd be one thing if this was just them showing how they learned something in a blog post... But this was meant for teaching.... And yet there's no description and clearly obvious bugs.
Could someone please tell me why his code is considered 'non-pythonic'? This statement worries me a little, because his code looks pretty similar to what I write.
- Getters and setters are used all over the place (setData, getData etc)
- Strangely named variables - eg List = [] and newNode = Node(data)
- Non-pythonic conditionals eg I'd expect while(temp.next != None): to read while temp.next:
- functions are commented outside the function instead of in docstrings, which, ironically would have made it much better for learning the algorithms :-)
Not that it's bad code, it's just not very pythonic.