John smith
John smith

Reputation: 33

how to find a modules path?

I'm trying to find a path but it doesn't have the __file__ attribute.

I'm trying to participate in an open project called instapy. so, I've started reading the code. I want the path of a function. in the code below, I've tried to print the '__file__' attribute but it gives an AttributeError. any other way to do this?

also, this is my first try on an open project. any suggestion would be really appreciated.

from instapy import InstaPy
from instapy import smart_run

print(smart_run.__file__)


Traceback (most recent call last):
  File "C:/Program Files/Python37(64)/Lib/site-packages/Test 2.py", line 5, in <module>
    print(smart_run.__file__)
AttributeError: 'function' object has no attribute '__file__'

Upvotes: 0

Views: 85

Answers (1)

ipaleka
ipaleka

Reputation: 3967

Modules are files, not functions like in your case where you tried to get the corresponding file for the smart_run function.

import instapy

print(instapy.__file__)

Upvotes: 1

Related Questions