Tuesday, August 9, 2011

A dangerous Pitfall in using cPickle + import

 

Assuming you have a module : myfunc.py

from  defunc_single import *

And defunc_single have a class that is  :

class Hello :

       def __init__ (self) :

               self.name = “hello”

Now if you access this Hello via myfunc.py like this :

o = myfunc.Hello()

cPickle.dumps(o)


and write it using cPickle, the module defunc_single is also pickled into the file.



So that means along the way, if you felt that you wanted a new module : lovefunc_single.py  with a better Hello and you thought that you can just replace the import statement in myfunc.py to :



from lovefunc_single import *



The cPickle will fail  to load the existing data unless you stick to defunc_single.py

5 comments:

  1. I ԁo consider all of the сoncepts уou've introduced on your post. They are really convincing and will certainly work. Still, the posts are very short for novices. May just you please lengthen them a bit from next time? Thank you for the post.

    My site :: at home laser hair removal
    My webpage: visit This weblink

    ReplyDelete
  2. Hi there to every one, the contents existing at this web page are really awesome for people experience, well, keep
    up the nice work fellows.

    Feel free to visit my web site - best registry cleaner

    ReplyDelete
  3. Rеvitоl cream is far еxtгa of a preventative rather than a resolution.


    Ηere is my web-site: cyber-activist.com
    Also see my site - http://mrts.da.iscte.pt

    ReplyDelete
  4. Me and ozzy fucked more difficult, trying to show to our god!

    FUCK YES!' ahead of cumming inside my warm pussy. were still fucking

    Also visit my blog post :: hcg injections
    my webpage - hcg injections

    ReplyDelete
  5. Τhat is гeallу attention-grabbing,
    You're an overly skilled blogger. I have joined your rss feed and sit up for searching for extra of your wonderful post. Additionally, I'vе shared your site іn my sοcіal nеtωorkѕ

    Hегe is my wеb blog :: Learn Alot more

    ReplyDelete