[Python] How do apps / scripts typically store information that is supposed to be used again?

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on a python script that generates a json of "jobs" (inputs for analysis).

    Each job has its own unique (Job #1, Job #2, Job #3, ...). However, the script I have written so far works in such a way that the "id" assigned to each job depends on the id when the script is ran. Meaning that if I run the script 3 times, it will give me Job #{1, 2, 3, 1, 2, 3, 1, 2, 3}. This happens because script needs to be fed data independently each time.

    Question: What I would like to do is store the lastID in somewhere , and start naming the first job of each script run from lastID+1. Is there a convention to do this? I was thinking of creating a .txt file and reading/writing to it each time. Is there a more efficient way to do this and keep it to a single .py file (i.e. not have to generate a .txt file)? How do apps typically do that?

    Thank you all!

    Continue reading...

Compartilhe esta Página