About hashing, classes and other things: Hi, i'm watching the lectures and doing the problem set's and I am enjoying very much the course, and it was OK until he started talking about hashing, the concept is a bit confusing for me, and with classes it's even worse. There is any site that can help me with these specific issues?
Classes are blueprints or templates for objects. They define the attributes ( think nouns ) of the object and the methods/functions ( think verbs, actions ) that the object can do. When you create ( instantiate ) an object, it basically creates a copy of the class and starts it up.
Hmm, so you can think of a class like pre-made attributes and functions that you can use into the objects that you put in that class? For exemple, when you made A = class_name() I can use the pre-made functions of class_name in the object A and some of these functions may assign attributes to the object A in the form of A.attribute_name = attribute_value? It's something like that? It isn't clear in my mind (especially when you use 'self', __init__ and the why of these "__")but I think if I keep watching the lectures I could catch it.
I feel the same way, was doing good and really liked the lectures until this hashing and classing came along. I feel very confused with the topics, but like Rafael said Im just going to keep watching the lectures and try and catch it. It doesn't help that the solutions they gave for problem set 5 do not work too. It keeps giving me a unhandled exception in thread started by <function main_thread at 0x02F6BE30>. rsmith's explanation was a bit helpful tho, thanks!
Okay, I haven't seen the lectures, so I tried to keep it light. __init__() is the initialization method/function. It's called when an object is instantiated/created. In languages like Java and C++ the constructor ( __init__() ) has the EXACT same name as the class. An object is it's own name space. This is the reason for all those self references. self.variable in a class will ultimately refer to your object's variable, not the variable in __main__, or if you imported say time, in time's name space. The Python documentation for the version of Python that you're using ( I hope it's version 2.something! ) includes a PDF called tutorial.pdf that may be helpful to you. http://www.python.org
I think that reading more about that and your comments I understood better, also re-watching the Recitation number 5 helped a lot. Thank you very much rsmith6559! :)
Also this documentation is very helpful!
Glad to help.
Join our real-time social learning platform and learn together with your friends!