How does one identify if python script was run for the first time?
<p>I've been wondering if there's any way to find out if a python script was run for the first time.</p>

<p>Let's suppose I have this simple program:</p>

<pre><code>import random
import string
from uuid import getnode


def get_mac():
    return getnode()


def generate_unique_id():
    return ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_uppercase) for _ in range(20))


def main():
    get_mac()
    generate_unique_id()

if __name__ == '__main__':
    main()
</code></pre>

<p>I'd like to know if there's any way to find / count the number of times a program is being run on a Windows machine.</p>

<p>Any other workarounds are welcome.</p>

<p><strong> If you want to keep track of all the times your software was run </strong></p>

<p>There really is no way without writing to a file every time you start, and then appending to this file. So that way, you'd simply go look up the file to keep track of your program.</p>

<p><strong> If you want to see when the last time your software was compiled </strong></p>

<p>I guess another thing you could technically do is check the date of your generated compiled python bytecodes, but this would only tell you the last time your program executed, not the first time or the total number of times.</p>

<p><a href="http://stackoverflow.com/questions/237079/how-to-get-file-creation-modification-date-times-in-python">This link shows you how to check for the creation/modification/update times</a>
<a href="http://stackoverflow.com/questions/237079/how-to-get-file-creation-modification-date-times-in-python"></a>.</p>

python windows python-3.x