Everyone! I'm trying to make a Python 3.3 program recognize that it is the first time the user has used the program. I'm not sure how to proceed or if it's possible.
-
2You can let the file rewrite itself, or either make a separate buffer file beside the file or in a default OS temp map. In OS X you could make a .plist file in the Library. In *nix you could store a hidden .file in the userfolder. In Windows you could use the Registry. Mostly I'm curious about for what reason you do this. Maybe there is a better way :) – Apr 08 '13 at 19:45
-
2You need a user preference mechanism. – David Heffernan Apr 08 '13 at 19:45
-
2See [this answer](http://stackoverflow.com/questions/200599/whats-the-best-way-to-store-simple-user-settings-in-python) for how to build a simple user preference mechanism around `ConfigParser`, and [this answer](http://stackoverflow.com/questions/10644183/how-to-store-variables-preferences-in-python-for-later-use) for where to put the file (except that it doesn't handle Apple guidelines on OS X). – abarnert Apr 08 '13 at 19:52
5 Answers
you need to
Write something somewhere
a> Create A File somewhere
b> write a registry key
c> register use with some website
or probably any other number of ways to do it

- 110,522
- 12
- 160
- 179
I just created a file in the program directory, and used os.path.exists to make Python recognize the user's first time use.

- 731
- 5
- 16
- 36
You could keep a text file containing a list of all the users that have used the program and then compare against it during the execution of the program.

- 2,484
- 1
- 13
- 9
You could create a file in running directory containing a firststartup flag, i used that for a java program, havent used python much.
psuedocode: maybe this will help you find the answer.
- check if file exists
- if file does exist assume it is not first time, else, if file does not exist create the file and asume that it is indeed first startup.
- rest of program.

- 456
- 5
- 17
As bad as sounds, you should probably use a file, like the others are saying. It sounds bad because I am guessing you don't want to write files you don't have to, but in all honesty, it will work out well.
one way you could do it, is have a 'firstuse.txt' in the directory when the user starts it, and when it runs, it deletes that file. That way you can keep things a little cleaner.

- 6,659
- 8
- 31
- 42