Thanks guys,
NamedTuple implementation is preety nice solution.
--nitin
On Thu, Aug 19, 2010 at 6:28 PM, Peter Otten <__pete...@web.de> wrote:
> Peter Otten wrote:
>
> > Nitin Das wrote:
> >
> >> class mymut(object):
> >>
> >> def __setattr__(self,k,v):
> >> if hasattr(self,k):
> >>
Peter Otten wrote:
> Nitin Das wrote:
>
>> class mymut(object):
>>
>> def __setattr__(self,k,v):
>> if hasattr(self,k):
>> if self.__dict__.get(k) == None:
>> self.__dict__[k] = v
>> else:
>> raise TypeError("Cant Modify Attribute Value")
>
Nitin Das wrote:
> class mymut(object):
>
> def __setattr__(self,k,v):
> if hasattr(self,k):
> if self.__dict__.get(k) == None:
> self.__dict__[k] = v
> else:
> raise TypeError("Cant Modify Attribute Value")
> else:
> raise T
On Thu, 19 Aug 2010 01:24:11 pm Nitin Das wrote:
> Hello,
>
> Can somebody help me how to make immutable objects in python. I
> have seen overriding the __new__, __setattr__ methods.. but not
> comfortable with how to use them to make the object immutable.
>
> thanks in advance
> --nitin
I ha
"Nitin Das" wrote
class mymut(object):
def __setattr__(self,k,v):
if hasattr(self,k):
if self.__dict__.get(k) == None:
self.__dict__[k] = v
Do you need to look up the dict?
Surely you could just use
if self.k is None
self.k = v
which looks a lot simpler to
class mymut(object):
def __setattr__(self,k,v):
if hasattr(self,k):
if self.__dict__.get(k) == None:
self.__dict__[k] = v
else:
raise TypeError("Cant Modify Attribute Value")
else:
raise TypeError("Immutable Object")
class m
Hello,
Can somebody help me how to make immutable objects in python. I have
seen overriding the __new__, __setattr__ methods.. but not comfortable with
how to use them to make the object immutable.
thanks in advance
--nitin
___
Tutor maillist - T
On 11/1/06, Danny Yoo <[EMAIL PROTECTED]> wrote:
> here is the stack> trace. i know that SOAPpy is doing wrong by not checking the type of> the element along with id(ele).> I thought if there is any work around the problem i could use that without
> upgrading SOAPpy after it is fixed.Hi Premnath,Y
> here is the stack
> trace. i know that SOAPpy is doing wrong by not checking the type of
> the element along with id(ele).
> I thought if there is any work around the problem i could use that without
> upgrading SOAPpy after it is fixed.
Hi Premnath,
You might want to see if some other SOAP mod
On 10/31/06, Danny Yoo <[EMAIL PROTECTED]> wrote:
> Im facing a problem with SOAPpy which checks for recursive objects using> id(obj).>> In my case value for 2 SOAP headers are same and iam getting a recursion> error. if i pass different object with same value SOAPpy does not complain
> (by using s
> Im facing a problem with SOAPpy which checks for recursive objects using
> id(obj).
>
> In my case value for 2 SOAP headers are same and iam getting a recursion
> error. if i pass different object with same value SOAPpy does not complain
> (by using str(value) and unicode(value)).
If you can inc
Premnath Sah wrote:
> I would like to know how i can guarantee that a new immutable object is
> infact a new object.
>
> Example:
>
> >>> a = 1
> >>> b = 1
> >>> a is b
> True
>
> is what i get. i want a and b to be two different object.
I don't think there is any way to control this for th
On 10/31/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
Premnath Sah wrote:> I would like to know how i can guarantee that a new immutable object is> infact a new object.>> Example:>> >>> a = 1> >>> b = 1
> >>> a is b> True>> is what i get. i want a and b to be two different object.I don't think th
Hi,from http://docs.python.org/ref/objects.htm """Types affect almost all aspects of object behavior. Even the importance of object identity is affected in some sense: for immutable types, operations that compute new values may actually return a reference to any existing object with the same type a
14 matches
Mail list logo