Created
September 25, 2017 09:39
-
-
Save dz0/38ccdffd8e85e08753b0b8616c3194b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a, b = None, None | |
| def __init__(a_, b_): | |
| global a, b | |
| a = a_ | |
| b = b_ | |
| def add(): | |
| return a+b | |
| def mult(): | |
| return a*b | |
| def scale(k): | |
| global a, b | |
| a *= k | |
| b *= k | |
| ################# ----Refactor--->> | |
| class Arithmetics(object): | |
| def __init__(self, a_, b_): | |
| global a, b | |
| self.a = a_ | |
| self.b = b_ | |
| def add(self): | |
| return self.a + self.b | |
| def mult(self): | |
| return self.a * self.b | |
| def scale(self, k): | |
| self.a *= k | |
| self.b *= k |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment