Commits

Lucian Brănescu-Mihăilă committed 7c28591 Draft

Explicit counter value property. String handles unicode, altough perhaps there should be a separate explicit type.

  • Participants
  • Parent commits f745971

Comments (0)

Files changed (1)

     def __init__(self, name, content=None):
         self.name = name
 
-        if content and isinstance(str, content):
-            r.set(self.name, content)
+        if content:
+            if isinstance(str, content):
+                r.set(self.name, content)
+            elif isinstance(unicode, content):
+                r.set(self.name, content.encode('utf-8'))
 
     def __repr__(self):
         return repr(r.get(self.name))
 
+    def __str__(self):
+        return str(r.get(self.name))
+
+    def __unicode__(self):
+        return r.get(self.name).decode('utf-8')
+
     def __len__(self):
         return r.strlen(self.name)
 
 
         self.set(value)
 
-    def set(self, value):
+    @property
+    def value(self):
+        return r.get(self.name)
+
+    @value.setter
+    def value(self, value):
         if value and isinstance(int, value):
             r.set(self.name, value)
 
-    def get(self):
-        return r.get(self.name)
-
     def __repr__(self):
         return repr(r.get(self.name))