Last active
October 31, 2017 22:41
-
-
Save grihabor/2fd02d1c80c8f13289c8596489594455 to your computer and use it in GitHub Desktop.
Define all class attributes inside the constructor
This file contains 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
class X: | |
def __init__(self): | |
self.a = 'a' | |
self.b = None | |
self.c = None | |
def run(self, b) | |
self.b = b | |
x = X() | |
x.c = 'c' | |
x.run('b') | |
print(x.a, x.b, x.c) | |
#|a b c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment