Skip to content

Instantly share code, notes, and snippets.

@yosisa
Created March 6, 2011 14:35
Show Gist options
  • Save yosisa/857334 to your computer and use it in GitHub Desktop.
Save yosisa/857334 to your computer and use it in GitHub Desktop.
class Foo:
def __init__(self, *names):
for name in names:
def getter(name):
def _getter(self):
return "[[ {0} ]]".format(name)
return _getter
setattr(Foo, name, property(fget=getter(name)))
foo = Foo("foo", "bar", "baz")
print foo.foo
print foo.bar
print foo.baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment