Help: pickle module unable to load "rb" mode files in linux

Discussion in 'Python' started by Surya Kasturi, Apr 2, 2013.

  1. Hi, hope you can help me on it..

    with open(pickle_f, 'r') as fhand:
    obj = pickle.load(fhand)


    This works on linux but not in windows until I use "rb" mode while
    creating file object. Surprisingly, the "rb" mode is not working on Linux..
    raising EOFError.

    Why is this happening?
    Surya Kasturi, Apr 2, 2013
    #1
    1. Advertising

  2. Surya Kasturi? 2013?4?2????UTC+8??10?54?25????
    > Hi, hope you can help me on it..
    >
    >
    >
    > with open(pickle_f, 'r') as fhand:
    >         obj = pickle.load(fhand)
    >
    >
    >
    >
    > This works on linux but not in windows until  I use "rb" mode while creating file object. Surprisingly, the "rb" mode is not working on Linux..raising EOFError.
    >

    Just use a decorator with a pass in parameter about the OS
    to wrap the two versions in different platforms.

    By the way any function can be saved in a variable to
    be passed around means that the lambda 1-liner is not
    necessarily required in Python.

    In C++, the sub-classing with virtual membership function
    reload mechanism is the equivalent part.
    88888 Dihedral, Apr 7, 2013
    #2
    1. Advertising

  3. Surya Kasturi? 2013?4?2????UTC+8??10?54?25????
    > Hi, hope you can help me on it..
    >
    >
    >
    > with open(pickle_f, 'r') as fhand:
    >         obj = pickle.load(fhand)
    >
    >
    >
    >
    > This works on linux but not in windows until  I use "rb" mode while creating file object. Surprisingly, the "rb" mode is not working on Linux..raising EOFError.
    >

    Just use a decorator with a pass in parameter about the OS
    to wrap the two versions in different platforms.

    By the way any function can be saved in a variable to
    be passed around means that the lambda 1-liner is not
    necessarily required in Python.

    In C++, the sub-classing with virtual membership function
    reload mechanism is the equivalent part.
    88888 Dihedral, Apr 7, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. a pickle's pickle

    , Aug 2, 2005, in forum: Python
    Replies:
    4
    Views:
    382
  2. paragk
    Replies:
    5
    Views:
    1,069
    Peter Otten
    May 18, 2010
  3. Peter Otten
    Replies:
    0
    Views:
    102
    Peter Otten
    Apr 2, 2013
  4. Surya Kasturi
    Replies:
    0
    Views:
    126
    Surya Kasturi
    Apr 7, 2013
  5. Peter Otten
    Replies:
    0
    Views:
    120
    Peter Otten
    Apr 7, 2013
Loading...

Share This Page