Created
October 28, 2016 20:10
-
-
Save ehermes/960657f32ca96c4daa760ef3f6724120 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
| #!/usr/bin/env python | |
| class Foo(object): | |
| def __new__(cls, *args, **kwargs): | |
| new_foo = super(Foo, cls).__new__(cls) | |
| new_foo.x = None | |
| new_foo.y = None | |
| new_foo.z = None | |
| return new_foo | |
| class Bar(Foo): | |
| def __init__(self, x): | |
| self.x = x | |
| class Baz(Foo): | |
| def __init__(self, y): | |
| self.y = y | |
| my_bar = Bar(1) | |
| my_baz = Baz(2) | |
| print(my_bar.x) | |
| print(my_bar.y) | |
| print(my_baz.x) | |
| print(my_baz.y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment