Comment by pgcj_poster
7 years ago
> you can easily write programs that edit themselves
Hah! I can do that too:
#!/usr/bin/env python3
#
# script.py
# Copyright 2019 pgcj_poster
print('Hello World')
with open('script.py', 'w') as f:
f.write(f.read().replace('Hello World', 'Goodbye World'))
Clearly Lisp is of no use in 2019.
You should use '__file__' for increased generality.
Note that you can also import a module and refer to its location on disk as 'module.__file__'. I may or may not have used this to modify a few core python modules in place.