Re: immutability is not strictly the same as having an unchangeable value, it is more subtle

2019-04-18 Thread Chris Angelico
On Thu, Apr 18, 2019 at 6:16 PM Gregory Ewing wrote: > > Arup Rakshit wrote: > > What protocols I need to > > learn, to define a custom immutable class ? > > That depends on how strictly you want to enforce immutability. > > The easiest thing is not to enforce it at all and simply refrain > from m

Re: immutability is not strictly the same as having an unchangeable value, it is more subtle

2019-04-18 Thread Gregory Ewing
Arup Rakshit wrote: What protocols I need to learn, to define a custom immutable class ? That depends on how strictly you want to enforce immutability. The easiest thing is not to enforce it at all and simply refrain from mutating it. This is very often done. You can provide some protection a

Re: immutability is not strictly the same as having an unchangeable value, it is more subtle

2019-04-17 Thread Arup Rakshit
Hi All, Thanks for explaining it so nice way. I got it now. What protocols I need to learn, to define a custom immutable class ? Thanks, Arup Rakshit a...@zeit.io > On 16-Apr-2019, at 10:54 PM, Dennis Lee Bieber wrote: > > On Tue, 16 Apr 2019 13:13:18 +0530, Arup Rakshit declaimed the >

Re: immutability is not strictly the same as having an unchangeable value, it is more subtle

2019-04-16 Thread Chris Angelico
On Tue, Apr 16, 2019 at 5:44 PM Arup Rakshit wrote: > > Hi, > > I am reading a sweet introduction about Python object from [3.1. Objects, > values and > types](https://docs.python.org/3/reference/datamodel.html#objects-values-and-types). > And here the author is said about the Object values nic

Re: Immutability of Floats, Ints and Strings in Python

2016-11-28 Thread Random832
On Fri, Nov 25, 2016, at 06:33, Ned Batchelder wrote: > A Python implementation can choose when to reuse immutable objects and > when not to. Reusing a value has a cost, because the values have to > be kept, and then found again. So the cost is only paid when there's > a reasonable chance that the

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Steve D'Aprano
On Fri, 25 Nov 2016 10:37 pm, Ned Batchelder wrote: > And: floats are rarely checked for equality, and very very very rarely > used as dict keys, so there's no gain by short-circuiting the equality > check. You cannot short-circuit the equality check, at least not without giving up IEEE-754 seman

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Ned Batchelder
On Friday, November 25, 2016 at 7:17:08 AM UTC-5, BartC wrote: > On 25/11/2016 11:24, Nikunj wrote: > > > > Out of curiosity, I wanted to understand the reason behind having different > > memory location for two identical floats . This is unlike ints or strings. > > Tried googling but couldn't fi

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread BartC
On 25/11/2016 11:24, Nikunj wrote: Out of curiosity, I wanted to understand the reason behind having different memory location for two identical floats . This is unlike ints or strings. Tried googling but couldn't find anything concrete. Any links or references would be appreciated! Do you

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Ned Batchelder
On Friday, November 25, 2016 at 6:34:00 AM UTC-5, Ned Batchelder wrote: > On Friday, November 25, 2016 at 6:24:47 AM UTC-5, Nikunj wrote: > > Hi All, > > > > Out of curiosity, I wanted to understand the reason behind having different > > memory location for two identical floats . This is unlike i

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Ned Batchelder
On Friday, November 25, 2016 at 6:24:47 AM UTC-5, Nikunj wrote: > Hi All, > > Out of curiosity, I wanted to understand the reason behind having different > memory location for two identical floats . This is unlike ints or strings. > Tried googling but couldn't find anything concrete. Any links o

Re: Immutability and Python

2012-11-07 Thread Thomas Rachel
Am 29.10.2012 16:20 schrieb andrea crotti: Now on one hand I would love to use only immutable data in my code, but on the other hand I wonder if it makes so much sense in Python. You can have both. Many mutable types distinguish between them with their operators. To pick up your example,

Re: Immutability and Python

2012-10-30 Thread rusi
On Oct 31, 1:45 am, Neal Becker wrote: > rusi wrote: > > On Oct 29, 8:20 pm, andrea crotti wrote: > > > >> Any comments about this? What do you prefer and why? > > > Im not sure how what the 'prefer' is about -- your specific num > > wrapper or is it about the general question of choosing mutabl

Re: Immutability and Python

2012-10-30 Thread Neal Becker
rusi wrote: > On Oct 29, 8:20 pm, andrea crotti wrote: > >> Any comments about this? What do you prefer and why? > > Im not sure how what the 'prefer' is about -- your specific num > wrapper or is it about the general question of choosing mutable or > immutable types? > > If the latter I would

Re: Immutability and Python

2012-10-30 Thread rusi
On Oct 29, 8:20 pm, andrea crotti wrote: > Any comments about this? What do you prefer and why? Im not sure how what the 'prefer' is about -- your specific num wrapper or is it about the general question of choosing mutable or immutable types? If the latter I would suggest you read http://en.wi

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 15:45:59 -0700, Chris Kaynor wrote: > On Mon, Oct 29, 2012 at 3:30 PM, Steven D'Aprano > wrote: >> On Mon, 29 Oct 2012 17:05:07 +, andrea crotti wrote: >> >>> I meant how do I create new immutables classes myself, I guess that's >>> possible writing C extensions but I don'

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 15:20:02 +, andrea crotti wrote: > I have a philosofical doubt about immutability, that arised while doing > the SCALA functional programming course. "Philosophical". Like most words derived from the ancient Greeks, the "F" sound uses "ph" rather than "f". > Now suppose

Re: Immutability and Python

2012-10-29 Thread Chris Kaynor
On Mon, Oct 29, 2012 at 3:30 PM, Steven D'Aprano wrote: > On Mon, 29 Oct 2012 17:05:07 +, andrea crotti wrote: > >> I meant how do I create new immutables classes myself, I guess that's >> possible writing C extensions but I don't see in pure Python.. > > Well, you can't *quite* make a truly i

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
On Tue, 30 Oct 2012 06:36:52 +1100, Chris Angelico wrote: > On Tue, Oct 30, 2012 at 6:23 AM, Ian Kelly > wrote: >> _MyImmutableClass = namedtuple('MyImmutableClass', 'field1 field2 >> field3 field4') >> >> class MyImmutableClass(_MyImmutableClass): > > Question: Is it clearer to take advantage o

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 17:05:07 +, andrea crotti wrote: > I meant how do I create new immutables classes myself, I guess that's > possible writing C extensions but I don't see in pure Python.. Well, you can't *quite* make a truly immutable class in pure-Python, because if *your* Python code can

Re: Immutability and Python

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 1:36 PM, Chris Angelico wrote: > Question: Is it clearer to take advantage of the fact that the base > class can be an arbitrary expression? > > class MyImmutableClass(namedtuple('MyImmutableClass', 'field1 field2 > field3 field4')): > > You lose the unnecessary temporary a

Re: Immutability and Python

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 6:23 AM, Ian Kelly wrote: > _MyImmutableClass = namedtuple('MyImmutableClass', 'field1 field2 > field3 field4') > > class MyImmutableClass(_MyImmutableClass): Question: Is it clearer to take advantage of the fact that the base class can be an arbitrary expression? class M

Re: Immutability and Python

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 10:12 AM, andrea crotti wrote: > Also because how doi I make an immutable object in pure Python? I sometimes use namedtuples for this. from collections import namedtuple MyImmutableClass = namedtuple('MyImmutableClass', 'field1 field2 field3 field4') If you want default

Re: Immutability and Python

2012-10-29 Thread Devin Jeanpierre
On Mon, Oct 29, 2012 at 12:46 PM, Paul Rubin wrote: > andrea crotti writes: >> Also because how doi I make an immutable object in pure Python? > > Numbers in Python are already immutable. What you're really looking for > is a programming style where you don't bind any variable more than once. N

Re: Immutability and Python

2012-10-29 Thread Terry Reedy
On 10/29/2012 1:05 PM, andrea crotti wrote: I meant how do I create new immutables classes myself, I guess that's possible writing C extensions but I don't see in pure Python.. If you mean class with immutable instances, mutate new instances in __new__ instead of __init__ and write a custom .

Re: Re: Immutability and Python

2012-10-29 Thread Evan Driscoll
On 10/29/2012 12:05 PM, andrea crotti wrote: > I meant how do I create new immutables classes myself, I guess that's > possible writing C extensions but I don't see in pure Python.. The short answer is: you don't, not really, except by using NamedTuple if that gives you what you want. The longer

Re: Immutability and Python

2012-10-29 Thread Terry Reedy
On 10/29/2012 11:20 AM, andrea crotti wrote: I have a philosofical doubt about immutability, that arised while doing the SCALA functional programming course. In real life, the physical world, things have mutable state, at least down to the atomic level. Do you only want to model mathematical w

Re: Immutability and Python

2012-10-29 Thread Paul Rubin
andrea crotti writes: > Also because how doi I make an immutable object in pure Python? Numbers in Python are already immutable. What you're really looking for is a programming style where you don't bind any variable more than once. This gives rise to a programming style that Python can support

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Chris Angelico : > On Tue, Oct 30, 2012 at 2:55 AM, Paul Rubin wrote: >> andrea crotti writes: >>> and we want to change its state incrementing the number ... >>> the immutability purists would instead suggest to do this: >>> def increment(self): >>> return NumWrapper(self

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Jean-Michel Pichavant : > > > 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 sugg

Re: Immutability and Python

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 2:55 AM, Paul Rubin wrote: > andrea crotti writes: >> and we want to change its state incrementing the number ... >> the immutability purists would instead suggest to do this: >> def increment(self): >> return NumWrapper(self.number + 1) > > Immutability puris

Re: Immutability and Python

2012-10-29 Thread Jean-Michel Pichavant
- Original Message - > 2012/10/29 Jean-Michel Pichavant : > > > > "return NumWrapper(self.number + 1) " > > > > still returns a(nother) mutable object. > > > > So what's the point of all this ? > > > > JM > > > > Well sure but it doesn't modify the first object, just creates a new > one.

Re: Immutability and Python

2012-10-29 Thread Paul Rubin
andrea crotti writes: > and we want to change its state incrementing the number ... > the immutability purists would instead suggest to do this: > def increment(self): > return NumWrapper(self.number + 1) Immutability purists would say that numbers don't have "state" and if you're tr

Re: Immutability and Python

2012-10-29 Thread Mark Lawrence
On 29/10/2012 15:20, andrea crotti wrote: I have a philosofical doubt about immutability, that arised while doing the SCALA functional programming course. Now suppose I have a simple NumWrapper class, that very stupidly does: class NumWrapper(object): def __init__(self, number): s

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 andrea crotti : >> > > Well sure but it doesn't modify the first object, just creates a new > one. There are in general good reasons to do that, for example I can > then compose things nicely: > > num.increment().increment() > > or I can parallelize operations safely not caring about th

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Jean-Michel Pichavant : > > "return NumWrapper(self.number + 1) " > > still returns a(nother) mutable object. > > So what's the point of all this ? > > JM > Well sure but it doesn't modify the first object, just creates a new one. There are in general good reasons to do that, for examp

Re: Immutability and Python

2012-10-29 Thread Jean-Michel Pichavant
- Original Message - > I have a philosofical doubt about immutability, that arised while > doing > the SCALA functional programming course. > > Now suppose I have a simple NumWrapper class, that very stupidly > does: > > class NumWrapper(object): > def __init__(self, number): >

Re: Immutability

2006-07-01 Thread [EMAIL PROTECTED]
That is why I don't like the use of @property. Even though the decorator is a nice short-hand notation, it is more confusing in my oppinion. So someone is more likely still call the property as a function when looking at: class C: @property def data(self): return 42 rather than if

Re: Immutability

2006-06-30 Thread Georg Brandl
Georg Brandl wrote: > Steve Holden wrote: >> Georg Brandl wrote: >>> Steve Holden wrote: >> [...] >>> Would it make sense, in the single argument case, to default the doc value to fget.__doc__ to support that use case, or should we just not create read-only properties by using proper

Re: Immutability

2006-06-29 Thread Kay Schluehr
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> writes: > |> Nick Maclaren wrote: > |> > The way that I read it, Python allows only values (and hence types) > |> > to be immutable, and not class members. The nearest approach to the > |> > latter is to use

Re: Immutability

2006-06-29 Thread Georg Brandl
Steve Holden wrote: > Georg Brandl wrote: >> Steve Holden wrote: > [...] >> >>>Would it make sense, in the single argument case, to default the doc >>>value to fget.__doc__ to support that use case, or should we just not >>>create read-only properties by using property as a decorator? >> >> >>

Re: Immutability

2006-06-29 Thread Steve Holden
Georg Brandl wrote: > Steve Holden wrote: [...] > >>Would it make sense, in the single argument case, to default the doc >>value to fget.__doc__ to support that use case, or should we just not >>create read-only properties by using property as a decorator? > > > This is actually already the ca

Re: Immutability

2006-06-29 Thread Georg Brandl
Steve Holden wrote: > Georg Brandl wrote: >> Nick Maclaren wrote: >> >>>In article <[EMAIL PROTECTED]>, >>>"Fredrik Lundh" <[EMAIL PROTECTED]> writes: >>>|> >>>|> identical? you only applied @property to one of the methods, and then >>>you're >>>|> surprised that only one of the methods were tu

Re: Immutability

2006-06-29 Thread Steve Holden
Georg Brandl wrote: > Nick Maclaren wrote: > >>In article <[EMAIL PROTECTED]>, >>"Fredrik Lundh" <[EMAIL PROTECTED]> writes: >>|> >>|> identical? you only applied @property to one of the methods, and then >>you're >>|> surprised that only one of the methods were turned into a property? >> >>I w

Re: Immutability

2006-06-28 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : > Georg Brandl a écrit : (snip) >> >> That's another sign that property isn't intended to be used as a >> decorator. >> Normally, decorators wrap functions with other functions. > > > Normally, decorators take a function and return anything appropriate. > >> proper

Re: Immutability

2006-06-28 Thread Bruno Desthuilliers
Georg Brandl a écrit : > Steve Holden wrote: > > Thanks very much. And, what's more, I have even found its documentation! Whatsnew2.2. The 2.4.2 reference is, er, unhelpful. >>> >>> >>>Is it? >>> >>>http://docs.python.org/lib/built-in-funcs.html >>> >>>documents "property" quite well. >

Re: Immutability

2006-06-28 Thread Bruno Desthuilliers
Georg Brandl a écrit : > Nick Maclaren wrote: > >>In article <[EMAIL PROTECTED]>, >>"Fredrik Lundh" <[EMAIL PROTECTED]> writes: >>|> >>|> identical? you only applied @property to one of the methods, and then >>you're >>|> surprised that only one of the methods were turned into a property? >> >>

Re: Immutability

2006-06-28 Thread Georg Brandl
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > "Fredrik Lundh" <[EMAIL PROTECTED]> writes: > |> > |> identical? you only applied @property to one of the methods, and then > you're > |> surprised that only one of the methods were turned into a property? > > I wasn't expecting EITHER to

Re: Immutability

2006-06-28 Thread Georg Brandl
Duncan Booth wrote: > Georg Brandl wrote: > >> In my opinion property isn't really meant to be used as a decorator since >> it's impossible to create a read-write property. The decorator pattern >> doesn't really fit here. >> > I agree that property isn't currently intended to be used as a decora

Re: Immutability

2006-06-28 Thread Duncan Booth
Georg Brandl wrote: > In my opinion property isn't really meant to be used as a decorator since > it's impossible to create a read-write property. The decorator pattern > doesn't really fit here. > I agree that property isn't currently intended to be used as a decorator, but it isn't actually *i

Re: Immutability

2006-06-28 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> writes: |> |> well, I completely fail to see how the following is compatible with the |> interpretation "attaches a non-default property, but doesn't do anything |> else": Because I was using a decorator and defining an attribut

Re: Immutability

2006-06-28 Thread Fredrik Lundh
Nick Maclaren wrote: > I wasn't expecting EITHER to be turned INTO a property - I was expecting > both methods to be the same, but one would have non-default properties > attached to it. > |> that's what the documentation > |> says, and that's what your code is doing. > > Er, no, it doesn't. Wh

Re: Immutability

2006-06-28 Thread Bruno Desthuilliers
Fredrik Lundh wrote: > Bruno Desthuilliers wrote: > > >>>class fred : >>>@property >>>def joe (self) : >>>print "Inside /joe\n" >> >> >>properties dont work properly on old-style classes (lookup 'new-style >>classes' on python.org, in the documentation menu), hence the strange >>b

Re: Immutability

2006-06-28 Thread Roel Schroeven
Nick Maclaren schreef: > > Most especially since it isn't working very well for me, and I am trying > to track down why. When I run: > class fred : > @property > def joe (self) : > print "Inside /joe\n" > > a = fred() > a.joe() > > I get: > > Inside joe > > Traceback (most rec

Re: Immutability

2006-06-28 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "Fredrik Lundh" <[EMAIL PROTECTED]> writes: |> |> identical? you only applied @property to one of the methods, and then you're |> surprised that only one of the methods were turned into a property? I wasn't expecting EITHER to be turned INTO a property - I was ex

Re: Immutability

2006-06-28 Thread Fredrik Lundh
Bruno Desthuilliers wrote: >> class fred : >> @property >> def joe (self) : >> print "Inside /joe\n" > > > properties dont work properly on old-style classes (lookup 'new-style > classes' on python.org, in the documentation menu), hence the strange > behaviour you observe. propert

Re: Immutability

2006-06-28 Thread Fredrik Lundh
Nick Maclaren wrote: > |> a property looks like an attribute, not a method, so you're trying to call > whatever > |> your "joe()" method returns. > > Well, yes, that was pretty obvious - but what was NOT obvious is why it > should do that for one of two identical methods. identical? you only ap

Re: Immutability

2006-06-28 Thread Bruno Desthuilliers
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > Sion Arrowsmith <[EMAIL PROTECTED]> writes: > |> > |> Actually, there's an almost throw-away mention in > |> http://docs.python.org/ref/descriptor-invocation.html > |> which gives you what you need (although not, I have to say, in an > |> ea

Re: Immutability

2006-06-28 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "Fredrik Lundh" <[EMAIL PROTECTED]> writes: |> |> a property looks like an attribute, not a method, so you're trying to call whatever |> your "joe()" method returns. Well, yes, that was pretty obvious - but what was NOT obvious is why it should do that for one of

Re: Immutability

2006-06-28 Thread Fredrik Lundh
Nick Maclaren wrote: > class fred : >@property >def joe (self) : >print "Inside /joe\n" > > a = fred() > a.joe() > > Traceback (most recent call last): > File "crap.py", line 14, in >a.joe() > TypeError: 'NoneType' object is not callable > > VERY weird - I could understand it

Re: Immutability

2006-06-28 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, Sion Arrowsmith <[EMAIL PROTECTED]> writes: |> |> Actually, there's an almost throw-away mention in |> http://docs.python.org/ref/descriptor-invocation.html |> which gives you what you need (although not, I have to say, in an |> easily digestible form). Thanks ver

Re: Immutability

2006-06-28 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "Gerard Flanagan" <[EMAIL PROTECTED]> writes: |> |> There are (unofficial) documentation wikis here: |> |> pytut.infogami.com |> pyref.infogami.com |> pyfaq.infogami.com Thanks very much. |> You might like to consider adding the information you perce

Re: Immutability

2006-06-28 Thread Sion Arrowsmith
Fredrik Lundh <[EMAIL PROTECTED]> wrote: >Sion Arrowsmith wrote: >> What I've not seen documented anywhere is the: >>@property >>def fset(self, value): >>... >> idiom. It's not obvious from the documentation of the property >> function that it can be used as a decorator

Re: Immutability

2006-06-28 Thread Georg Brandl
Steve Holden wrote: >>>Thanks very much. And, what's more, I have even found its documentation! >>>Whatsnew2.2. The 2.4.2 reference is, er, unhelpful. >> >> >> Is it? >> >> http://docs.python.org/lib/built-in-funcs.html >> >> documents "property" quite well. >> > I can't really agree that "

Re: Immutability

2006-06-28 Thread Fredrik Lundh
Sion Arrowsmith wrote: > What I've not seen documented anywhere is the: >@property >def fset(self, value): >... > idiom. It's not obvious from the documentation of the property > function that it can be used as a decorator like this. probably because it cannot be used

Re: Immutability

2006-06-28 Thread Gerard Flanagan
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > Georg Brandl <[EMAIL PROTECTED]> writes: > |> > > |> > Thanks very much. And, what's more, I have even found its documentation! > |> > Whatsnew2.2. The 2.4.2 reference is, er, unhelpful. > |> > |> Is it? > |> > |> http://docs.python.org/li

Re: Immutability

2006-06-28 Thread Steve Holden
Georg Brandl wrote: > Nick Maclaren wrote: > >>In article <[EMAIL PROTECTED]>, >>Robert Kern <[EMAIL PROTECTED]> writes: >>|> Nick Maclaren wrote: >>|> > The way that I read it, Python allows only values (and hence types) >>|> > to be immutable, and not class members. The nearest approach to the

Re: Immutability

2006-06-28 Thread Sion Arrowsmith
Nick Maclaren <[EMAIL PROTECTED]> wrote: >Georg Brandl <[EMAIL PROTECTED]> writes: >|> [ attributions lost ] >|> > Thanks very much. And, what's more, I have even found its documentation! >|> > Whatsnew2.2. The 2.4.2 reference is, er, unhelpful. >|> Is it? >|> http://docs.python.org/lib/built-in-

Re: Immutability

2006-06-28 Thread Bruno Desthuilliers
Nick Maclaren wrote: > The way that I read it, Python allows only values (and hence types) > to be immutable, I don't understand this sentence. Some types are immutable, some are not. This has nothing to do with "values" (FWIW, everything in Python is an object, there's no 'primitive type' vs 'obj

Re: Immutability

2006-06-28 Thread Diez B. Roggisch
> Sigh. No. It's terrible. What it documents is the use of the property > FUNCTION. It does not document what properties ARE, and how they interact > with the rest of the language. Until you know that, it is so ambiguous > as to be almost totally useless - and it is THAT information that needs

Re: Immutability

2006-06-28 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, Georg Brandl <[EMAIL PROTECTED]> writes: |> > |> > Thanks very much. And, what's more, I have even found its documentation! |> > Whatsnew2.2. The 2.4.2 reference is, er, unhelpful. |> |> Is it? |> |> http://docs.python.org/lib/built-in-funcs.html |> |> documen

Re: Immutability

2006-06-28 Thread Georg Brandl
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> writes: > |> Nick Maclaren wrote: > |> > The way that I read it, Python allows only values (and hence types) > |> > to be immutable, and not class members. The nearest approach to the > |> > latter is to use t

Re: Immutability

2006-06-28 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> writes: |> Nick Maclaren wrote: |> > The way that I read it, Python allows only values (and hence types) |> > to be immutable, and not class members. The nearest approach to the |> > latter is to use the name hiding conventions. |> >

Re: Immutability

2006-06-28 Thread Robert Kern
Nick Maclaren wrote: > The way that I read it, Python allows only values (and hence types) > to be immutable, and not class members. The nearest approach to the > latter is to use the name hiding conventions. > > Is that correct? You can also make properties that don't allow writing. class Foo(