-1

Here is code:

def test():
    //restarting python
    os.execv(sys.executable, [sys.executable] + sys.argv)
print("Successfull")
return("Succesfull")

It's restarting python but not returning or printing value.

nrs
  • 937
  • 3
  • 17
  • 42

1 Answers1

1

I think your indentation is not correct so please have look at beloow code:

def test():
    try:
        print("Successfull")
        return("Succesfull")
    except Exception:
        #do something
    finally:
        os.execv(sys.executable, [sys.executable] + sys.argv)


test()

Note: The finally statement will be executed even if an exception was caught.

Shanteshwar Inde
  • 1,438
  • 4
  • 17
  • 27
  • How can i return "succesull" before executing os.execv(sys.executable, [sys.executable] + sys.argv) – nrs Apr 01 '19 at 06:16
  • 1
    @rts Why would you even want to return "successful" *before* runing `execv`? – zvone Apr 01 '19 at 06:42