I'm trying to create a small CLI tool and store a UUID for the user, thinking about having it generate it on a detected first run of the bash script. Is there a "pythonic" way to do so and handle unique user identification?
            Asked
            
        
        
            Active
            
        
            Viewed 44 times
        
    1
            
            
        - 
                    1Look for a specific file on startup. If it's found, read the UUID from it. Otherwise, create it, generate a new UUID, and write that to the newly created file. – chepner Nov 26 '19 at 17:19
 - 
                    Interesting, I found this solution related to it (https://stackoverflow.com/questions/24608665/how-to-store-python-application-data) would this be a recommended pattern or would it be too hacky? – OmegaNalphA Nov 26 '19 at 17:21
 - 
                    1That's fine. You might consider following the XDG base directory specification, which allows the user to specify where such files go. Your tool would create a directory under `$XDG_CONFIG_HOME` for its own configuration files. – chepner Nov 26 '19 at 17:26
 - 
                    1@chepner's solution works. But if you're creating a product that you plan on releasing and are relying on the integrity of this check, then I would avoid writing to a file. The user could easily "hack" around that by deleting it. – Brian Nov 26 '19 at 18:31
 - 
                    Thats effectively what I'm worried about. My app is not too important that it needs to worry about generating a new user if one deletes it, but it would be nice to track which user is which. Unsure if there is a way to get someone's MAC address maybe? – OmegaNalphA Nov 27 '19 at 07:59