[Tutor] cPickle and shjelving

Warren P. Jones WPJones at ewation.co.za
Wed Aug 24 11:26:38 CEST 2011


Hi,

I am new to python. I am having slight issue in using the cPickle and shelving function.

Here is what i want the program need to do:

Open an file with employees in it with relevant information like: employee number, surname and department. I also need to add an employee with the relevant information without rewriting the current data.

I have tried the code but not completely sure what i am doing wrong.

Here is the code that i tried:

# Defines
pickles["employee_num"]

    pickle_file = shelve.open("empl.dat")
           print "Add new Employee"
           employee_num = raw_input("\nEmployee number: ")
           surname = raw_input("Surname: ")
           name = raw_input("Name: ")
           department = raw_input("Department: ")

           ########################
           #    Storing DATA      #
           ########################

           cPickles.dump(employee_num, emp1.dat)

           print key, "-",pickles[key]
           pickles.sync () # Makes sure date is written

Can you please help me in solving this issue?


Kind regards
Warren  Jones



________________________________

This E-mail and any attachment(s) to it are for the addressee's use only.
It is strictly confidential and may contain legally privileged information. No confidentiality or privilege is waived or lost by any mis-transmission. If you are not the intended addressee, then please delete it from your system and notify the sender immediately. You are hereby notified that any use, disclosure, copying or any action taken in reliance on it is strictly prohibited and may be unlawful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110824/596eb195/attachment-0001.html>


More information about the Tutor mailing list