Python Forum
with statement odd feature
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
with statement odd feature
#4
that was code that was not intended to be read. it was processed by another script. i should have fixed it before posting. and you are right about the except. but i expected it to throw syntax errors in the compile phase. i guess it compiled the raise in place of them.

this should be better:

#!/usr/bin/env python3
import os,sys
a='~/.'+(sys.argv[0].rsplit('/',1)[1])
try:
    with open(os.path.expanduser(a+'-pre.py')) as f:
        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')) as f:
        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])
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
with statement odd feature - by Skaperen - May-11-2020, 08:13 PM
RE: with statement odd feature - by ndc85430 - May-12-2020, 04:51 AM
RE: with statement odd feature - by buran - May-12-2020, 05:03 AM
RE: with statement odd feature - by Skaperen - May-12-2020, 11:43 PM
RE: with statement odd feature - by buran - May-13-2020, 04:19 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020