Hacker News new | ask | show | jobs
by r3dey3 3239 days ago
You must not have looked at linked list. Besides being non-pythonic and having get and set functions, they don't even consistently use them.

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.

2 comments

> Besides being non-pythonic

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.

I only looked at the linked_list but there are a few examples that jump out straight away:

- 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.

I disagree with the idea that teaching is all about teaching students to copy the teacher. Teaching is about lighting a fire, and it's obviously lit in this case. Mission accomplished.
How was a fire lit in this case? I don't see how someone who wasn't already extremely motivated could get anything from this, and there are much better sources for motivated students.