Created
January 17, 2015 16:49
-
-
Save JeffCohen/3f328abf0cecbf29ff2c to your computer and use it in GitHub Desktop.
Why does python let me do this?
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
# Python 3.4 | |
# A nice class | |
class Person: | |
def __init__(self, name): | |
self.name = name | |
# A nice function | |
def speak(): | |
print("Woof!") | |
# A nice person | |
jeff = Person("Jeff") | |
# A bad thing! | |
jeff.s = speak | |
jeff.s() # => "Woof!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment