import sys import shelve try: outCredit = shelve.open( "credit.dat" ) except IOError: print >> sys.stderr, "File could not be opened" sys.exit( 1 ) outCredit[ "2" ] = "data" outCredit.close() # close shelve file