On Wed, Apr 18, 2012 at 9:56 AM, cheung <mwpche...@gmail.com> wrote: > how does the function "dir" works, where can I get the python-c source of > dir in py2.7 project. > > I looked the python_c source for hours, can't find how dir works.
http://hg.python.org/cpython/file/67be12ab8948/Objects/object.c#l1957 > for example: > if a user input a *.py source file like foo.py, i wanna parse the file, and > find all the functions and all the classes in the foo.py. Without actually executing the file? Then you should probably forget about dir() and use the ast module for parsing. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list