Commits

Doug Hellmann  committed 61ec593

add more examples

  • Participants
  • Parent commits 07a6fee

Comments (0)

Files changed (2)

File dynamic_attribute_lookup.py

+class MyClass(object):
+    
+    CLASS_ATTR = 'class value'
+    
+    def __init__(self, arg):
+        self.attr = arg
+
+o = MyClass('instance value')
+print o.attr
+print o.CLASS_ATTR

File using_regex.py

+import re
+
+pattern = 'this'
+text = 'Does this text match the pattern?'
+
+match = re.search(pattern, text)
+
+s = match.start()
+e = match.end()
+
+print 'Found    :', match.re.pattern
+print 'In       :', match.string
+print 'Range    :', s, '-', e
+print 'Substring:', text[s:e]