Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inspect.getfile () vs inspect.getsourcefile()

Tags:

python

I was just going through the inspect module docs.

What exactly is the difference between:

inspect.getfile()

and

inspect.getsourcefile()

I get exactly the same file path (of the module) for both.

like image 224
Jibin Avatar asked Jul 20 '11 11:07

Jibin


1 Answers

getfile():

Return the name of the (text or binary) file in which an object was defined. This will fail with a TypeError if the object is a built-in module, class, or function.

getfile() also returns pyc (compiled) files, where as getsourcefile() will only return source files.

like image 146
Jacob Avatar answered Oct 23 '22 13:10

Jacob