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
2 Antworten
+ 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.