Timeline for Opening a file in Python
Current License: CC BY-SA 4.0
2 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 5, 2020 at 16:14 | comment | added | Webucator |
If you execute a script using a relative path (e.g., python my_file.py ), then __file__ will be relative. You're right that a downside is that you cannot import the function unless it's in the same directory. You could fix this by accepting __file__ as a 2nd param.
|
|
Feb 5, 2020 at 1:55 | history | answered | Roland Illig | CC BY-SA 4.0 |