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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Custom Angular Filter Example</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> | |
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | |
</head> | |
<body> |
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
class MyClass(object): | |
def __init__(self, msg): | |
self.msg = msg | |
def say_stuff(self): | |
print("Standard say stuff message: {}\n\n".format(self.msg)) | |
ob = MyClass("Here is the original message") | |
def say_stuff(): |
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
class MyClass(object): | |
def __init__(self, msg): | |
self.msg = msg | |
def say_stuff(self): | |
print("Standard say stuff message: {}\n\n".format(self.msg)) | |
def say_other_stuff(self): | |
print("New say_stuff says this: {}\n\n".format(self.msg)) |
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
class MyClass(object): | |
pass | |
ob = MyClass() | |
def say_stuff(self): | |
print("The say stuff message here is: {}\n\n".format(self.msg)) | |
setattr(MyClass, "say_stuff", say_stuff) | |
setattr(ob, "msg", "Patched in message for patched in class") |
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
class MyClass(object): | |
def say_stuff(self): | |
print("Say stuff message is: {}\n\n".format(self.msg)) | |
ob = MyClass() | |
setattr(ob, "msg", "Here is a message from a setattr") | |
ob.say_stuff() |
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
class MyClass(object): | |
def say_stuff(self): | |
print("Say stuff message is: {}\n\n".format(self.msg)) |
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
class MyClass(object): | |
def say_stuff(self): | |
print("Say stuff message is: {}\n\n".format(self.msg)) | |
class OtherClass(object): | |
def __init__(self, msg): | |
self.msg = msg | |
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
say_stuff = MyClass.say_stuff | |
say_stuff(ob1) |
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
class MyClass(object): | |
def __init__(her, msg): | |
her.msg = msg | |
def say_stuff(her): | |
print("Say stuff message is: {}\n\n".format(her.msg)) | |
# normal call and instantiation | |
ob1 = MyClass("Hello there, This is me.") | |
ob1.say_stuff() |
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
class MyClass(object): | |
def __init__(self, msg): | |
self.msg = msg | |
def say_stuff(self): | |
print("Say stuff message is: {}\n\n".format(self.msg)) | |
# normal call and instantiation | |
ob1 = MyClass("Hello there, first example.") |
NewerOlder