I managed, thank you all, so the code, excludes the class, I created a while that runs while the counter is smaller than the number of lines and inside it I put if and Elif calling the functions according to the variable "a" and the functions stayed inside Try and inside the functions themselves that have the code I put the Return to exit the function in moments of error or delay to load or etc... and when it returns it respects the Try that tells exactly what to do modifying the variable "a"
I do not know if I explained well or if the code was ideal but it is the first code in . py that I do, worked out but with time I improve. Thanks again, you were instrumental.
a = 5
while CONTADOR_CNPJ <= dfcount:
if a == 0:
try:
consulta(CONTADOR_CNPJ)
a = 1
except:
a = 15
elif a == 1:
try:
CLICA_CLIENTE()
a = 2
except:
a = 15
elif a == 15:
try:
ERRO()
a = 0
except:
a = 5
elif a == 2:
try:
GRAVAR = COPIA_DADOS(y)
a = 3
except:
a = 15
elif a == 3:
try:
CONTADOR_CNPJ = FIM(GRAVAR, CONTADOR_CNPJ)
a = 0
except:
a = 15
elif a == 10:
try:
CNPJ = df.loc[CONTADOR_CNPJ, 'CNPJ']
CNPJ = str('%014d' % int(CNPJ))
arq.write(CNPJ + "||" 'NAO ENCONTRADO')
CONTADOR_CNPJ = CONTADOR_CNPJ + 1
a = 0
except:
a = 15
elif a == 4:
try:
iden()
a = 0
except:
a = 5
elif a == 5:
try:
nav = webdriver.Chrome()
logar(login, senha)
a = 4
except:
a = 15
This call as I understand it is a Goto, what you don’t have in Python, what you can try is the @de_python answer. Remembering that Goto is not considered a good practice
– rnd_rss
Good guy, misspelled, it’s exact Goto, thank you
– Toniano santos claro
The bigger question is in what moment you miss a drop when working with Python. It’s within a loop?
break
andcontinue
are better ways of flow control. Within a function? Usereturn
to get out of it at any point. parole? Put the code to which the goto would redirect into the condition (better still, in a function to be called conditionally). Avoid errors? Is there atry
andexcept
for that reason.– jfaccioni
better Paste some of the code you want to work - small anoints with just one if and print when you need to, to create a complete and minimal example. Otherwise a correct answer turns into a full functional programming class, and not necessarily you will understand, why is it unclear where you are missing.
– jsbueno