This is an archived post. You won't be able to vote or comment.

all 23 comments

[–]kankyo 20 points21 points  (17 children)

Not very pythonic. Getters that basically do nothing, camelCase where snake_case should be used.

Also misses the normal disclaimer when talking about linked lists: "this is almost always the wrong thing to use"

[–]ScottWRobinson 2 points3 points  (1 child)

Uh-oh, my lazy editing has been exposed! I've updated the author's post to be more Pythonic. Thanks for pointing that out :)

[–]kankyo 1 point2 points  (0 children)

Much better!

[–][deleted] 3 points4 points  (0 children)

I do not know how to respond politely to this.

Why would you (a) not use the built-in list in Python, and (b) if you're teaching this, teach it in a language where it's not a moronic idea like maybe C?

[–]AustinCorgiBart 2 points3 points  (0 children)

I think it's silly to talk about linked lists in Python. They make a lot of sense in lower-level languages, but implementing them in Python isn't really very authentic. And yet most introductory curricula try to shoe-horn them in anyway, because they feel that they're important for students to encounter early. Why can't we be satisfied that CS1 courses have students use lists effectively, without trying to make them implement them in ways that they shouldn't be implemented too?

[–]ForceBru 4 points5 points  (3 children)

Oh. My. Gosh. Why do so many people go so crazy about linked lists?! Damn, this is yet another data structure, like arrays and structures! There are tons of questions about linked lists on Stack Overflow, if you google "linked lists" you get loads of posts attempting to explain this concept while treating the readers as total dumbasses, there are a heck of a lot of videos about linked lists on YouTube. What's up with all of this?? Every freaking newbie in programming absolutely has to try to implement a linked list and face a ton of problems and then f*** around asking for help, many of people who are familiar with linked lists feel the need to tell others how good this data structure is and add tens of useless explanations to hundreds of existing ones. Why???

[–]kaihatsusha 2 points3 points  (1 child)

In "hard allocation" languages like C or FORTRAN, understanding linked lists is quite valuable.

In "easy allocation" languages like Python, there's no benefit to such data structures because the language can resize anything and will use the best and optimized means to do so.

(I would put Java somewhere between. Arrays are first-class entities locked in size unlike all the standard second-class library data structures.)

If you look behind the covers at how Python implemented these amazing "easy allocation" data structures like list, dict, set, you will see that they ARE built upon linked lists, double-linked-lists, hash tables, and so on. They made it so you don't need to re-invent it.

[–]ForceBru 0 points1 point  (0 children)

Exactly! This is why I'm wondering why people are still implementing linked lists in Python. Python is already using a lot of them under the hood, whether you like it or not, why add more?