Skip to content

Instantly share code, notes, and snippets.

@dz0
Created September 25, 2017 09:39
Show Gist options
  • Select an option

  • Save dz0/38ccdffd8e85e08753b0b8616c3194b5 to your computer and use it in GitHub Desktop.

Select an option

Save dz0/38ccdffd8e85e08753b0b8616c3194b5 to your computer and use it in GitHub Desktop.
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