Thanks a lot.

Actually you are right I would be trying same thing now.
Writing my own custom serializable for the object.

But everyone else who face the same problem would come up with their own
Serializable code.

Can't we plug something into cpickle So that it discards some variable from 
being serializable. Similar to __data for private variables. But on second 
thought that would be too much of change that I am asking.

Anyway thanks a lot.

regards
prasad chandrasekaran










--- Cancer cures smoking

#-----Original Message-----
#From: Tarek Ziadé [mailto:[EMAIL PROTECTED]
#Sent: Tuesday, October 18, 2005 1:01 PM
#To: Iyer, Prasad C
#Cc: python-list@python.org
#Subject: Re: Don't want to serialize a variable of object
#
#Iyer, Prasad C wrote:
#
#>Hi,
#>I got a class which I need to serialize, except for couple of variable.
#>i.e.
#>
#>import cPickle as p
#>class Color:
#>    def __init__(self):
#>        print "hello world"
#>        self.x=10
#>        self.somechar="this are the characters"
#>color=Color()
#>f=file('poem.txt', 'w')
#>p.dump(color, f)
#>f.close()
#>
#>How do I serialize the object color without serializing the x and
#>somechar variables?
#>Is there any modifier which prevents the variable from being serialized.
#>
#>
#You can create your own serialization process, by providing some kind of
#serialize() method
# in a base class that would dump part of the object.
#
#Let's say, the instance __dict__ dictionnary ?
#this serialize method can then remove the attributes that starts with '_v_'
#(that's what we do in Zope to avoid pickling some attribute)
#
#>
#>
#>
#>Another question:
#>      Is there a concept of private variables?
#>
#>
#That's a long discussion, you should look at the archives in the list.
#
#But anyway, all attributes that starts with '__' are considered private
#to the class.
#(ie: can't be reached by "instance.__attribute")
#
#even though you can find it if you dig into instance.__dict__
#
#
#Regards,
#
#Tarek


This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient,  you are not authorized 
to read, print, retain, copy, disseminate,  distribute, or use this message or 
any part thereof. If you receive this  message in error, please notify the 
sender immediately and delete all  copies of this message.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to