0

What is the difference between __file__ and "source.py"

In this code: https://code.sololearn.com/cCyj9p4Ny07R/?ref=app I find that __file__ & "source.py" have same data But "__file__=='source.py' " returns False

7th Sep 2019, 4:12 PM
Sousou
Sousou - avatar
2 ответов
+ 2
__file__ is a string which refers to the file "source.py" from the disk as "C:\Compiler\....\source.py" While "source.py" is a string which refers to the same file from the current folder. You performed basic string comparison on strings "C:\Compiler\....\source.py" and "string.py", that's why False was returned.
7th Sep 2019, 7:46 PM
Seb TheS
Seb TheS - avatar
7th Sep 2019, 7:52 PM
Seb TheS
Seb TheS - avatar