2012/10/29 Jean-Michel Pichavant <jeanmic...@sequans.com>:
>
>
> In an OOP language num.increment() is expected to modify the object in place.
> So I think you're right when you say that functional languages technics do 
> not necessarily apply to Python, because they don't.
>
> I would add that what you're trying to suggest in the first post was not 
> really about immutability, immutable objects in python are ... well 
> immutable, they can be used as a dict key for instance, your NumWrapper 
> object cannot.
>
>
> JM

Yes right immutable was not the right word, I meant that as a contract
with myself I'm never going to modify its state.

Also because how doi I make an immutable object in pure Python?

But the example with the dictionary is not correct though, because this:

In [145]: class C(object):
   .....:     def __hash__(self):
   .....:         return 42
   .....:

In [146]: d = {C(): 1}

works perfectly, but an object of class C can mutate as much as it
wants, as my NumWrapper instance..
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to