summaryrefslogtreecommitdiff
path: root/pypers/test_re.py
diff options
context:
space:
mode:
authormichele.simionato <devnull@localhost>2007-12-02 11:13:11 +0000
committermichele.simionato <devnull@localhost>2007-12-02 11:13:11 +0000
commit20ce686b0193d67ea56823a30551140f88b3aee1 (patch)
tree76015e7e4dc0b000bd857a2bdba6fb7976ac29a7 /pypers/test_re.py
parentf08f40335ad7f0ac961f25dabaaed34c4d4bcc44 (diff)
downloadmicheles-20ce686b0193d67ea56823a30551140f88b3aee1.tar.gz
Commited all py papers into Google code
Diffstat (limited to 'pypers/test_re.py')
-rwxr-xr-xpypers/test_re.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pypers/test_re.py b/pypers/test_re.py
new file mode 100755
index 0000000..1839d46
--- /dev/null
+++ b/pypers/test_re.py
@@ -0,0 +1,13 @@
+"""This script looks at its own source code and extracts dotted names,
+i.e. names containing at least one dot, such as object.attribute or
+more general one, such as obj.attr.subattr."""
+# Notice that dotted.names in comments and literal strings are ignored
+if __name__ == "__main__":
+ from oopp import *
+ import __main__
+ text = inspect.getsource(__main__)
+ regexp = Regexp.CODESEP| Regexp.DOTNAME()
+ print 'Using the regular expression',regexp
+ print "I have found the following dotted names:\n%s" % [
+ MO.group() for MO in regexp.finditer(text) if MO.lastgroup=='DOTNAME']
+