Since A2 part 1 was extended, I had a few days to think about the code I had pretty much finished and was about to turn in before I realized I could possibly improve it. Something I realized was that I could have my subclasses inherit __repr__ if I just initialized a name and had __repr__ use the name unique to the subclass. Since part 1 is mostly about inheritance, I'm thankful for the extension. (I also completely forgot about docstrings, so there's that. . .)
There was a question/answer posted in FAQ for A2 about using __repr__ to write __eq__. It said it depended on the quality of __repr__, but I'm not sure why that would be so, since __repr__ should be giving the name of the classes in addition to their children. Am I missing something?
I was a little confused on making attributes read-only after initialization. I understand its purpose and the general idea of it, but the actual implementation of it seemed foreign. Unless I really spaced out in class, I don't remember ever seeing property(get_x, set_y). I had to copy the code Professor Heap posted from the class and play around with it until it worked with my code. Either way, I'm feeling pretty confident about A2.
No comments:
Post a Comment