how python dir works

Vincent Vande Vyvre vincent.vandevyvre at swing.be
Wed Apr 18 12:45:24 EDT 2012


Le 18/04/12 18:15, Ian Kelly a écrit :
> On Wed, Apr 18, 2012 at 9:56 AM, cheung <mwpcheung at 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
Eventually the module pyclbr

http://docs.python.org/library/pyclbr.html?highlight=module#pyclbr.Class.module

Cheers

-- 
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte+7
<https://launchpad.net/qarte+7> . PaQager <https://launchpad.net/paqager>




More information about the Python-list mailing list