Skip to content

Conversation

@janash
Copy link
Contributor

@janash janash commented Aug 19, 2019

I've made a small edit to the Room class in the OOP version of the code.

Previously, there was a get_description function, which I've changed to use __str__. This is a so-called "magic method" in Python. They come with classes and can be overridden. The __str__ method defines how the object will print using the print command. I have changed main for this also.

Not necessary, but just a note on something you can do with Python!

@darrell24015 darrell24015 self-assigned this Aug 20, 2019
Copy link
Contributor

@darrell24015 darrell24015 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement. I like replacing concatenated strings with the new f-strings.

@darrell24015
Copy link
Contributor

darrell24015 commented Aug 20, 2019

Using __str__ is a perfect example. I'll try and include a description in the associated Blog to this repository. At the Aug 19th PyROA meeting, some other "dunders" came up in discussion and would be a great topic for a future meeting.

@darrell24015 darrell24015 merged commit 1caa8e1 into LearnToProgramRoanoke:master Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants