1

The title sums it up, what is the difference between __file__ and os.path.realpath(__file__)?

import os

print((__file__)) #/Users/tom/Documents/Code/Python/LearnPython/playingname.py
print(os.path.realpath(__file__)) #/Users/tom/Documents/Code/Python/LearnPython/playingname.py
print(type(__file__)) #<class 'str'>
print(type(os.path.realpath(__file__))) #<class 'str'>

Is os.path.realpath redundant?

Ch3steR
  • 20,090
  • 4
  • 28
  • 58

0 Answers0