[Tutor] Fwd: Help with basic user-data file

2006-10-12 Thread Rob Andrews
I'm forwarding this to the tutor list, as I'm swamped at work.

-- Forwarded message --
From: Asrarahmed Kadri [EMAIL PROTECTED]
Date: Oct 12, 2006 9:17 AM
Subject: Re: [Tutor] Help with basic user-data file
To: Rob Andrews [EMAIL PROTECTED]


Thanks.
Can you please also tell me how to check the existence of a file using
python builtin functions.


Regards,
Asrar


On 10/12/06, Rob Andrews [EMAIL PROTECTED] wrote:
 When a login name is being created, you can pull a list of existing
 login names from file, and run a check to see if it is in the list. If
 the new name is in the list, have it kick back a message telling the
 user to try another name.

 Also, your program could suggest a new user name in such a case, or
 even assign new users names of its choosing.

 The dictionary data structure is handy for the program to use in very
 efficiently matching user names with passwords. But you don't have to
 store the dictionary in a file as a dictionary. It's possible to do
 so, but often easier to use a delimited text file.

 On 10/12/06, Asrarahmed Kadri [EMAIL PROTECTED] wrote:
  It means there is no need of entering the data in the dictionary,??
 
  How will I then implement the uniqueness of loginnames???
 
  Thanks for the support.
  regards,
  Asrar
 
 
  On 10/12/06, Rob Andrews  [EMAIL PROTECTED] wrote:
  
   To keep the information, the simplest solution is simply to save it in
   a text file that the program can load into memory when it starts up
   again. For sensitive information like passwords, a little extra fuss
   is generally merited.
  
   When someone logs in, you can save a value like
   time.strftime(time.ctime()) for a nice, human-readable time stamp.
   Don't forget to import time first.
  
   -Rob A.
  
   On 10/12/06, Asrarahmed Kadri [EMAIL PROTECTED] wrote:
Folks,
   
I am trying to modify the userManagement program given in Core Python
Programming. It uses a dictionary to store user-password information.
  The
usernames are the keys and the passwords are the values.
Now I want is to add a third element; last login time.
I want to store this information in a file so that the data is not lost
  once
the program stops execution.
   
I am not sure of using time function in python..
Can anyone help with this issue??
   ___
   Tutor maillist  -   Tutor@python.org
   http://mail.python.org/mailman/listinfo/tutor
  
 
 
 
  --
  To HIM you shall return.


 --
 Blogging my outdoors obsession: http://trekkingbob.blogspot.com/
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor




-- 
To HIM you shall return.

-- 
Blogging my outdoors obsession: http://trekkingbob.blogspot.com/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: Help with basic user-data file

2006-10-12 Thread Kent Johnson
 From: Asrarahmed Kadri [EMAIL PROTECTED]
 Date: Oct 12, 2006 9:17 AM
 Subject: Re: [Tutor] Help with basic user-data file
 To: Rob Andrews [EMAIL PROTECTED]
 
 
 Thanks.
 Can you please also tell me how to check the existence of a file using
 python builtin functions.

If path is a string containing the full path to the file (absolute path 
or relative to the working dir) then use
import os
os.path.exists(path) # To see if the path represents *something* real
os.path.isfile(path) # check for a file specifically
os.path.isdir(path)  # check for a directory

Kent


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor