[Tutor] reset password program

ADRIAN KELLY kellyadrian at hotmail.com
Fri Dec 16 23:49:40 CET 2011


thanks dave,
just tried writing to file for the first time

def main():
 outfile.write('Hello this is a test')
 outfile.close()
main()

error, globalname outfile is not defined, do i need to import function to get this working?

   

> Date: Fri, 16 Dec 2011 17:13:04 -0500
> From: d at davea.name
> To: kellyadrian at hotmail.com
> CC: tutor at python.org
> Subject: Re: [Tutor] reset password program
> 
> On 12/16/2011 05:02 PM, ADRIAN KELLY wrote:
> > Hi guys,
> > i created a program that allows users to login using a password that i set at the top of the program.
> > Among other things users are given the option to change their password. My questions is;
> >
> > Is it possible for me to make this new password stick, in other words when they shut down and
> > log in again i am back to the original password.....the new password only works while the programming
> > is running. I know why this is happening, what i don't know is what to do about it.
> >
> > I am new to python and programming so if you have any ideas...
> >
> > please keep them simple.
> >
> > thanks all,
> > adrian 
> >
> Nothing in Python objects is persistent. If you want something to 
> survive till the next run, you have to write it to something external, 
> such as a file.
> 
> If this is a serious program, with important passwords, you'll want to 
> encrypt the file. If it's just casual, encode the file in some obscure 
> way. But if it's a class assignment, then save it in a text file, in a 
> directory you'll be able to find next time.
> 
> That last point is important. The program directory may be read-only to 
> that user. So you might not be able to store it there. One approach is 
> to save it in the user's home directory, so for me, it might be 
> /home/davea Convention is to start it with a leading period, so that 
> the ls command won't show it by default. Another question is whether 
> you want a different password per user, and if you might have more than 
> one user logged into your machine at the same time.
> 
> Hope this helped,
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> DaveA
> 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111216/4612684c/attachment-0001.html>


More information about the Tutor mailing list