Last week, I focused more on the assignment instead of the lecture. I feel like the most important thing we talked about in lecture is the difference between __repr__ and __str__. __repr__ expresses whatever was typed in the shell, while __str__ returns the exact form. For example, if a tree is typed in the shell, TreeList(1, Treelist(1, None, None ), None), __repr__ would return TreeList(1, Treelist(1, None, None ), None), while __str__ returns the tree form of the tree.
For the assignment, property was what I learnt most about. Property restrains the user from reassigning values to certain variables. I was confused in the beginning because I did not realize that I need to write codes for property, instead of writing property(getf, setf, delf, and whatever it is). Overall, I think the assignment worked out pretty good, and I look forward to work on part 2.
No comments:
Post a Comment