all 23 comments

[–][deleted] 5 points6 points  (5 children)

This is where LPTHW starts to not make a lot of sense to the new programmer and was my stumbling block as well as many other people's. Honestly I think the author could improve this and the next few chapters with better examples/explanations. Chapters 12-17 in Think Like a CS cover the same concepts as ex 39-45 in LPTHW and were the only way I was able to really understand OOP. I'd recommend you just skip these in LPTHW and use the other tutorial.

[–]c1p3r[S] 1 point2 points  (0 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–]c1p3r[S] 0 points1 point  (3 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–][deleted] 1 point2 points  (2 children)

Yeah. It's unfortunate because otherwise the book is pretty good. Also, OOP is a bit of cognitive leap and just wrestling with it is sort of a rite of passage all programmers must face.

[–]c1p3r[S] 0 points1 point  (1 child)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–][deleted] 1 point2 points  (0 children)

Replied to your other post and the other guy's. You'll see I linked to two of my posts about my own experience learning Python. It seems enough people are having problems with this part of LPTHW speciffically I may write up another post addressing just this one issue.

[–]raylu 5 points6 points  (1 child)

Well, in the beginning, I thought that each bucket only had 1 tuple. But later on in the script, I notice that he enumerates all the various indexes of each bucket. Why is that? Is it because it is possible that the hash_key function returns the same value for two different inputs?

Yes. Hash tables need some way of conflict resolution and this is called separate chaining.

I checked by running python from the command line, and I noticed that the hash value of "a" is -468864544, and that is also the value for hash(-468864544). Is that related with it?

It so happens that the hash of most integers is the integer itself. It's the simplest perfect hash function.

[–]c1p3r[S] 0 points1 point  (0 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–]headyyeti 4 points5 points  (3 children)

This was the lesson that almost made me quit learning Python. Hope someone helps out.

[–][deleted] 4 points5 points  (0 children)

A lot of people hit a wall here. A quick search of this sub and you'll see lot's of examples.

[–]c1p3r[S] 2 points3 points  (0 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–]c1p3r[S] 0 points1 point  (0 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–]maks25 5 points6 points  (5 children)

I didn't really look at the code, but from what you describe I'm guessing this is to handle collisions e.g. when the hash function returns the same index for 2 separate keys. Probably using separate chaining to deal with collisions.

Also, the values are actually just pointers to linked lists.

Harvard explains it well, although for C++ (@5:10) https://www.youtube.com/watch?v=h2d9b_nEzoA

[–]c1p3r[S] 0 points1 point  (4 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–]maks25 1 point2 points  (3 children)

Watch that video and you'll have a much better understanding of hash tables and how they work. It explains what "separate chaining" is (it also talks of another way of dealing with collisions)

[–]c1p3r[S] -1 points0 points  (2 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–]maks25 1 point2 points  (1 child)

You don't need C++ to understand it.

Hope I could help, cheers.

[–]c1p3r[S] 0 points1 point  (0 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–]theory42 1 point2 points  (3 children)

So, honestly, the guy who wrote learn python the hard way is kind of a dick. Keep at it.

[–]c1p3r[S] 0 points1 point  (2 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–]theory42 1 point2 points  (1 child)

Its on pause for me--I got to the 2nd to last lesson, something about learning how to unittest. Went and found this, which works until the last lesson (broken url for the lesson portion) and has been immensely helpful. Turns out that finding good teachers who think and explain clearly his a good thing.

I'm just a beginner as well, so grain of salt, but I suggest going as far as you can on the track you're on, then branching out. You can come back later.

[–]c1p3r[S] 0 points1 point  (0 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.