this where I am so far !

Marian poeta_sam at yahoo.com
Mon Dec 19 14:08:53 EST 2005


Any one who  have a clue how can I add and  remove records from a list. if the record is dictionary type)   This the program I am working on. I have no idea how can I remove and  add some more courses !
  
  
  
  
   import cPickle, shelve
  def  write_file():                                     
      CIT101 = ["Academic Computer Skills"]
      CIT111 = ["Database Management"]
      CIT115 = ["Intro to Computer scince"]
      CIT127 = ["ACCESS"]
      CIT211 = ["Systems Analysis and Design"]
      CIT216 = ["Visual Basic"]
      CIT218 = ["Intermediate Visual Basic"]
      CIT234 = ["Decision Support Using Excel"]
      pickle_file = open("pickles1.dat","w")
  
      cPickle.dump(CIT101, pickle_file)
      cPickle.dump(CIT111, pickle_file)
      cPickle.dump(CIT115, pickle_file)
      cPickle.dump(CIT127, pickle_file)
      cPickle.dump(CIT211, pickle_file)
      cPickle.dump(CIT216, pickle_file)
      cPickle.dump(CIT218, pickle_file)
      cPickle.dump(CIT234, pickle_file)
      print "A file has been created and the required specifications have been added"
      pickle_file.close
  
  
  
  def read_file():
      pickle_file = open("pickles1.dat","r")
      CIT101 = cPickle.load(pickle_file)
      CIT111 = cPickle.load(pickle_file)
      CIT115 = cPickle.load(pickle_file)
      CIT127 = cPickle.load(pickle_file)
      CIT211 = cPickle.load(pickle_file)
      CIT216 = cPickle.load(pickle_file)
      CIT218 = cPickle.load(pickle_file)
      CIT234 = cPickle.load(pickle_file)
      pickle_file.close()
  
  
      pickles = shelve.open("pickles2.dat")
      pickles["CIT101"] = ["Academic Computer Skills"]
      pickles["CIT111"] = ["Database Management"]
      pickles["CIT115"] = ["Intro to Computer scince"]
      pickles["CIT127"] = ["ACCESS"]
      pickles["CIT211"] = ["Systems Analysis and Design"]
      pickles["CIT216"] = ["Visual Basic"]
      pickles["CIT218"] = ["Intermediate Visual Basic"]
      pickles["CIT234"] = ["Decision Support Using Excel"]
  
      pickles.sync()
  
      for key in pickles.keys():
          print key, "-", pickles[key]
  
  def dele_file():
      word_dele = raw_input("Which record do u want to delete?: ")
  
      if word_dele in picles.keys():
          del word_dele
  
      else:
          print "There is no such record in file pickles2.dat"
      
      pickles.close()
  def display_instructions():
      """Display the Main menue"""
      print \
            """
          Main Manue:
            
            1. Exit
            2. Create a new file and add specifications
            3. (not working)Add more courses to the file
            4. Read the file
            5. (not working)Delete file
  
            """
      
  # exit the  program                                >>> 1 <<<
  def over_program():
      """Exit the program"""
      print "Good Bye!"
  
      
  def main():
      choice = None
      display_instructions()
      
      
      while choice != 1:
          choice = raw_input("\nChoice: ")
          if choice == "1":
              over_program()
              break
      
          elif choice == "2":
              write_file()
  
          elif choice == "3":
              add_to_file()
              
          
          elif choice == "4":
              read_file()
  
          elif choice == "5":
              delete_file()
          
  
  
          else:
              print "\nSorry, but", choice, "isn't a valid choice."
  
  
  
  main()
  raw_input("Press Enter Key to Exit.")    
  
  

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051219/5d842110/attachment.html>


More information about the Python-list mailing list