On Dec 17, 2005, at 2:00 PM, Nathan Pinno wrote:

Here is the latest error:
The Currency Exchange Program
By Nathan Pinno
 
Traceback (most recent call last):
  File "D:\Python24\exchange.py", line 27, in -toplevel-
    store = open('exch.txt', 'b')#load
IOError: invalid mode: b

[snip...]

store = open('exch.txt', 'b')#load
exch = pickle.load(store)
store.close()

It looks like what you are trying to do is read exch.txt as a binary file. The problem is that 'b' by itself is not a valid mode; it's a modifier to one of the other modes (r, w or a).

So to read a file in binary mode, what you want to do is:

store = open('exch.txt', 'rb')

Using your own code as an example, see how you implemented the save feature (option 9). That open() correctly uses the 'wb' flag to write the file in binary mode.

    elif menu_option == 9:
        store = open("exch.txt", 'wb') #save
        pickle.dump(exch, store)
        store.close()
        break

 -dan

-- 
Black holes are where God divided by zero.  -Steven Wright


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

Reply via email to