(May-11-2020, 08:13 PM)Skaperen Wrote: an editing error exposed this to me which i did not find in the reference manual. on a with statement i omitted the "with_item", that is, the as followed by the variable name. but it still worked. i was using the variable f. so, i left it out, and removed it in another with statement. the script still works. maybe, some day, it will break.
is this supposed to happen? is this a Cpython glitch?
#!/usr/bin/env python3 import os,sys a='~/.'+(sys.argv[0].rsplit('/',1)[1]) try: with open(os.path.expanduser(a+'-pre.py')): p=[x[:-1] for x in f] except: p=""" import os from subprocess import call,DEVNULL,PIPE,Popen,run from sys import stderr,stdin,stdout,version_info from time import sleep,time as secs """.splitlines() try: with open(os.path.expanduser(a+'-suf.py')): s=[x[:-1] for x in f] except: s=[] c='\n'.join(p+sys.argv[1:]+s) if len(sys.argv)>1:os.execvp('/usr/bin/env',['env','python3','-c',c])
well, with all-catching
except
what else do you expect? It throws an error and the except
block is executed always.By the way, how do you read this code with single space indentation per level? It's a nightmare
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs