summaryrefslogtreecommitdiff
path: root/pypers/pro6.py
diff options
context:
space:
mode:
Diffstat (limited to 'pypers/pro6.py')
-rwxr-xr-xpypers/pro6.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/pypers/pro6.py b/pypers/pro6.py
new file mode 100755
index 0000000..5039ca7
--- /dev/null
+++ b/pypers/pro6.py
@@ -0,0 +1,18 @@
+"""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
+
+from oopp import *
+import __main__
+
+text=inspect.getsource(__main__)
+
+dotname=Regexp.CODESEP| Regexp.DOTNAME.named()
+
+print 'Using the regular expression',dotname
+
+print "I have found the following dotted names:\n%s" % [
+ MO.group() for MO in dotname.finditer(text)]
+