Skip to content

Instantly share code, notes, and snippets.

@cra
Created August 22, 2014 12:10
Show Gist options
  • Select an option

  • Save cra/83e03d8382db901e59ff to your computer and use it in GitHub Desktop.

Select an option

Save cra/83e03d8382db901e59ff to your computer and use it in GitHub Desktop.
#!/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