Open shixnya opened 5 months ago
This change of behavior in Python 3.9+ is documented here. https://docs.python.org/3/whatsnew/3.9.html#other-language-changes
Python now gets the absolute path of the script filename specified on the command line (ex: python3 script.py): the file attribute of the main module became an absolute path, rather than a relative path.
Many examples under
examples/
use the following line to set the 'default' config file.if __file__ != sys.argv[-1]:
However, in Python 3.9+, this won't work because
__file__
is an absolute path.An easy way to fix it will be using something like:
if sys.argv[-1] in __file__:
Or, alternatively, we can change
__file__
toos.path.basename(__file__)
.There might be a better idea, so making an issue to discuss.