File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 3131
3232
3333def dirmod ():
34- r'''Same as dir(mod), but returns only functions, in the definition order'''
34+ r'''Returns all non-internal functions in a module
35+
36+ Same as dir(mod), but returns only functions, in the order of definition.
37+ Anything starting with _ is skipped
38+
39+ '''
3540 with open ('{}.py' .format (modname ), 'r' ) as f :
3641 for l in f :
37- m = re .match (r'def +([a-zA-Z0-9_]+ )\(' , l )
42+ m = re .match (r'def +([a-zA-Z0-9][a-zA-Z0- 9_]* )\(' , l )
3843 if m :
3944 yield m .group (1 )
4045
@@ -158,9 +163,6 @@ def write(s, verbatim):
158163 write ('* GLOBAL FUNCTIONS\n ' , verbatim = True )
159164
160165 for func in dirmod ():
161- if re .match ('_' , func ):
162- continue
163-
164166 if not inspect .isfunction (mod .__dict__ [func ]):
165167 continue
166168
You can’t perform that action at this time.
0 commit comments