pickle function reference ??

Discussion in 'Python' started by ted kelly, Nov 12, 2003.

  1. ted kelly

    ted kelly Guest

    It seems I can not deepcopy or pickle an object with an attribute that
    points to any function that is not a built in.
    I thought it should be ok as long as the function is defined in the top
    level of a module.
    What am I missing??
    ted kelly, Nov 12, 2003
    #1
    1. Advertising

  2. ted kelly <> writes:

    > It seems I can not deepcopy or pickle an object with an attribute that
    > points to any function that is not a built in.


    That is not true

    import pickle

    class A:
    pass

    a=A()
    a.attr=pickle.loads

    data=pickle.dumps(a)
    b=pickle.loads(data)
    print b.attr

    works fine for me.

    Regards,
    Martin
    Martin v. =?iso-8859-15?q?L=F6wis?=, Nov 12, 2003
    #2
    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. Michael Hohn
    Replies:
    3
    Views:
    1,129
    Dima Dorfman
    Oct 31, 2004
  2. a pickle's pickle

    , Aug 2, 2005, in forum: Python
    Replies:
    4
    Views:
    383
  3. Michele Simionato
    Replies:
    2
    Views:
    1,874
    Michele Simionato
    May 23, 2008
  4. Replies:
    6
    Views:
    1,846
    Steve Holden
    Jan 24, 2009
  5. Terry
    Replies:
    1
    Views:
    711
    Terry
    Aug 11, 2009
Loading...

Share This Page