magic-constants

Python equivalent of PHP's __DIR__ magic constant?

Python equivalent of PHP's __DIR__ magic constant? Question: In PHP, the __DIR__ magic constant evaluates to the path to the directory containing the file in which that constant appears. Is there an equivalent feature in Python? Asked By: user212218 || Source Answers: os.path.dirname(__file__) In Python 3.4 and newer, that’s it – you get an absolute …

Total answers: 2