Created
August 22, 2014 12:10
-
-
Save cra/83e03d8382db901e59ff 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
| #!/bin/env python2 | |
| # coding: utf-8 | |
| import types | |
| class Structure(object): | |
| ''' Some sort of a data container ''' | |
| def __init__(self, value=42): | |
| print "Creating structure with value = %s" % value | |
| self.value = value | |
| def show(self, symbol): | |
| ''' Actual visualisation function ''' | |
| print symbol*self.value + "\n" | |
| showtime = lambda self: show(self, '*') | |
| if __name__ == "__main__": | |
| s = Structure(19) | |
| s.show = types.MethodType(showtime, s) | |
| s.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment