Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-17 Thread Steve Holden
Piet van Oostrum wrote: >>Edward Elliott <[EMAIL PROTECTED]> (EE) wrote: > > >>EE> Piet van Oostrum wrote: >> >[EMAIL PROTECTED] (T) wrote: >>T> As you can see, the "constant" A can be modified this easily. But if >>T> there were an intuitive mechanism to declare a symbol to be i

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-15 Thread Piet van Oostrum
> Edward Elliott <[EMAIL PROTECTED]> (EE) wrote: >EE> Piet van Oostrum wrote: [EMAIL PROTECTED] (T) wrote: >>> >T> As you can see, the "constant" A can be modified this easily. But if >T> there were an intuitive mechanism to declare a symbol to be immutable, >T> then there won't be t

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-12 Thread Edward Elliott
Piet van Oostrum wrote: >> [EMAIL PROTECTED] (T) wrote: > >>T> As you can see, the "constant" A can be modified this easily. But if >>T> there were an intuitive mechanism to declare a symbol to be immutable, >>T> then there won't be this problem. > > Mutability is not a property of symbols b

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-12 Thread Piet van Oostrum
> [EMAIL PROTECTED] (T) wrote: >T> As you can see, the "constant" A can be modified this easily. But if >T> there were an intuitive mechanism to declare a symbol to be immutable, >T> then there won't be this problem. Mutability is not a property of symbols but of values. So it doesn't make se

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-09 Thread Christophe
Fredrik Lundh a écrit : > Christophe wrote: > > >>I think you've made a mistake in your example. > > > >>> constant A = [] > >>> def foo(var): > ... var.append('1') > ... print var > ... > >>> b = A > >>> foo(b) > >>> foo(b) > > >>>and this ? >>

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-05 Thread Fredrik Lundh
Christophe wrote: > I think you've made a mistake in your example. >>> constant A = [] >>> def foo(var): ... var.append('1') ... print var ... >>> b = A >>> foo(b) >>> foo(b) > > and this ? > > > > >>> constant A = [] > > >>> print A is A >

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-05 Thread Michele Simionato
Edward Elliott wrote: > Michele Simionato wrote: > >> >>> A = [] # let's declare a "constant" here > >> >>> b = A # and let's assign the constant here > >> >>> b.append('1') # OOPS! > > > > But it makes no sense to use a mutable object for a constant! > > The user should use a tuple, > > Sure.

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-04 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Yes, I know that "constant" A will also be modified as the b[0] points > to A. Obviously the [] should be marked as immutable, as A is declared > to be constant thus immutable. If somebody tries to modify this > immutable object an error would occur. > > When I furthe

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-04 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Bruno Desthuilliers wrote: > >>[EMAIL PROTECTED] a écrit : >> >>>Hi Pythonians, >>> >>>To begin with I'd like to apologize that I am not very experienced >>>Python programmer so please forgive me if the following text does not >>>make any sense. >>> >>>I have been mis

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-04 Thread Edward Elliott
Michele Simionato wrote: >> >>> A = [] # let's declare a "constant" here >> >>> b = A # and let's assign the constant here >> >>> b.append('1') # OOPS! > > But it makes no sense to use a mutable object for a constant! > The user should use a tuple, Sure. Now show me the builtin immutable equ

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-04 Thread Michele Simionato
Edward Elliott wrote: > Michele Simionato wrote: > > Python solution is to rely on the intelligence of programmers. If they > > see an all caps name and then they try to change it without knowing what > > they are doing, then they are stupid. If you have stupid programmers there > > is no way the l

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-04 Thread Christophe
Fredrik Lundh a écrit : > Christophe wrote: > > >>That's easy, since A is a symbolic constant know at compile time, and >>since it's a known mutable objet, the code once compiled will be >>equivalent to: >> >> >>> b = [[]] >> >> >>> # much later >> >>> b|0].append('1') > > > the OP talked about

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-04 Thread Fredrik Lundh
Christophe wrote: > That's easy, since A is a symbolic constant know at compile time, and > since it's a known mutable objet, the code once compiled will be > equivalent to: > > >>> b = [[]] > > >>> # much later > >>> b|0].append('1') the OP talked about constants as names for immutable object

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread Diez B. Roggisch
Edward Elliott wrote: > Michele Simionato wrote: >> Python solution is to rely on the intelligence of programmers. If they >> see an all caps name and then they try to change it without knowing what >> they are doing, then they are stupid. If you have stupid programmers >> there is no way the lang

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > What I'd like to see here is that b gets a copy of A so that the > original A won't be modified as we play with b. However, as we assign a > constant value A to b, I wouldn't want to restrict myself from playing > with b. If A is a list you can take a copy-slice liek th

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread Edward Elliott
Michele Simionato wrote: > Python solution is to rely on the intelligence of programmers. If they > see an all caps name and then they try to change it without knowing what > they are doing, then they are stupid. If you have stupid programmers there > is no way the language can stop them for makin

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread Michele Simionato
[EMAIL PROTECTED] wrote: > As stated in my first post, I am quite newbie in > Python and miss a simple and intuitive mechanism that would allow to > declare something as constant and that would protect these "constant" > objects from accidental modifications. > > T.S. Python solution is to rely on

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread Christophe
Fredrik Lundh a écrit : > [EMAIL PROTECTED] wrote: > > >>For example: >> >> >A = [] # let's declare a "constant" here >b = A # and let's assign the constant here >b.append('1') # OOPS! >c = A >print A >> >>['1'] >> >print b >> >>['1'] >> >print c >> >>['1'] >> >>As

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread tsaar2003
> are you sure you know how Python's object model work ? if you do, please > explain your proposal in terms of what needs to be changed, rather than in > terms of wishful thinking. No, I do not know. As stated in my first post, I am quite newbie in Python and miss a simple and intuitive mechanism

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Yes, I know that "constant" A will also be modified as the b[0] points > to A. Obviously the [] should be marked as immutable, as A is declared > to be constant thus immutable. If somebody tries to modify this > immutable object an error would occur. so a constant decla

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread tsaar2003
Yes, I know that "constant" A will also be modified as the b[0] points to A. Obviously the [] should be marked as immutable, as A is declared to be constant thus immutable. If somebody tries to modify this immutable object an error would occur. When I further thought about this problem with consta

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-02 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > For example: > > >>> A = [] # let's declare a "constant" here > >>> b = A # and let's assign the constant here > >>> b.append('1') # OOPS! > >>> c = A > >>> print A > ['1'] > >>> print b > ['1'] > >>> print c > ['1'] > > As you can see, the "constant" A can be modifie

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-02 Thread tsaar2003
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > > Hi Pythonians, > > > > To begin with I'd like to apologize that I am not very experienced > > Python programmer so please forgive me if the following text does not > > make any sense. > > > > I have been missing constants in Python langua

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-02 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi Pythonians, > > To begin with I'd like to apologize that I am not very experienced > Python programmer so please forgive me if the following text does not > make any sense. > > I have been missing constants in Python language. Why so ? I guess you're talking ab

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-02 Thread Ben Sizer
[EMAIL PROTECTED] wrote: > To begin with I'd like to apologize that I am not very experienced > Python programmer so please forgive me if the following text does not > make any sense. > > I have been missing constants in Python language. There are some > workarounds available, for example the const

Possible constant assignment operators ":=" and "::=" for Python

2006-04-28 Thread tsaar2003
Hi Pythonians, To begin with I'd like to apologize that I am not very experienced Python programmer so please forgive me if the following text does not make any sense. I have been missing constants in Python language. There are some workarounds available, for example the const-module. To me, this