aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-10-31 16:07:03 -0400
committerJesse Luehrs <doy@tozt.net>2014-10-31 16:07:03 -0400
commit59cbb7fc0211d2b74008540e5f53dbce606fbd67 (patch)
treecdcf9b4994fffb172a93819531e8e379a2e907ba
parenteed0b063a3520c0c55c4e147789e4bbb53e55416 (diff)
downloadpython-mop-59cbb7fc0211d2b74008540e5f53dbce606fbd67.tar.gz
python-mop-59cbb7fc0211d2b74008540e5f53dbce606fbd67.zip
add an attribute method to get the value at that attribute
-rw-r--r--mop/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/mop/__init__.py b/mop/__init__.py
index 554cc9c..c07b12e 100644
--- a/mop/__init__.py
+++ b/mop/__init__.py
@@ -227,6 +227,12 @@ def bootstrap():
name="get_body", body=gen_reader("body")
))
+ def get_value(self, instance):
+ return instance.slots[self.get_name()]
+ Attribute.add_method(Method.new(
+ name="get_value", body=get_value
+ ))
+
Class.add_attribute(Attribute.new(name="name"))
Class.add_attribute(Attribute.new(name="superclass"))
Class.add_attribute(Attribute.new(name="attributes", default=lambda: {}))