8 ms·
Anyone else getting this error? I tried on Debian 9 and MacOS 10.14.6 after installing via pip. import reloading Traceback (most recent call last): Fil
by PerryCox 7y ago
Anyone else getting this error? I tried on Debian 9 and MacOS 10.14.6 after installing via pip.
import reloading
Traceback (most recent call last):
File "<input>", line 1, in <module>
import reloading
File "/home/lucas.mccoy/.local/lib/python2.7/site-packages/reloading/__init__.py", line 1, in <module>
from .reloading import reloading
File "/home/lucas.mccoy/.local/lib/python2.7/site-packages/reloading/reloading.py", line 87
exc = exc.replace('File "<string>"', f'File "{fpath}"')
^
SyntaxError: invalid syntax
- julvo 7y agoIt only works with Python 3. Thanks for reminding me that I should add a note to the Readme.
- compressedgas 7y agoIt does work in Python 2 with the following patch: diff --git a/reloading/reloading.py b/reloading/reloading.py index 1d28e2f..1a5f981 100644 --- a/reloading/reloading.py +++ b/reloading/reloading.py @@ -84,9 +84,10 @@ def reloading(seq): exec(body) except Exception: exc = traceback.format_exc() - exc = exc.replace('File "<string>"', f'File "{fpath}"') + exc = exc.replace('File "<string>"', 'File "{}"'.format(fpath)) sys.stderr.write(exc + '\n') - input('Edit the file and press return to continue with the next iteration') + print('Edit the file and press return to continue with the next iteration') + sys.stdin.readline() # copy locals back into the caller's locals for k, v in locals().items():
- julvo 7y agoBrilliant, thank you. I'll patch that.
- progval 7y agoThat's an f-string, so it only works with Python 3.7 and later
- kbd 7y agof-strings were introduced in Python 3.6, fyi: https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep498 https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep49...