B
B
BadCats2021-12-19 00:16:50
Python
BadCats, 2021-12-19 00:16:50

Restarting a python script from a specific line?

There is the following task: to restart the python script from a certain line - skipping those that have already worked out before. If we generalize the task - without importing part of the code as a module, without breaking it into functions - is it possible to do the following:

statement_1
statement_2
statement_3
statement_4
statement_5
statement_6

When restarting the script - start execution, for example with statement_3 ?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vindicar, 2021-12-19
@BadCats

No, it won't. Example:

a = 1
b = 2
print(a+b)

Explain what behavior you expect from restarting the script from the third line without executing the first two.

H
HemulGM, 2021-12-19
@HemulGM

Can. Save the state to a file. Restart the script. After starting, check the status and start from the right place.

A
alexbprofit, 2021-12-19
@alexbprofit

You want to do something that looks like a breakpoint, but first?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question