Steven D'Aprano wrote:
> Most of the common built-in Python objects are immutable:
> ...
> while a few are mutable:
>
> lists
> dicts
> sets
Also, bytearrays.
--
Tom Zych / freethin...@pobox.com
___
Tutor maillist - Tutor@python.org
To unsubscribe
only holds one member, the
list to which a refers
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/
- Original Message
> From: Andre Engels
> To: Alan Gauld
> Cc: tutor@python.org
> Sent: Monday, 14 March, 2011 9:23:47
> Subject:
On Mon, Mar 14, 2011 at 9:56 AM, Alan Gauld wrote:
> "Yasar Arabaci" wrote
>
>> >>> a=["a"]
>> >>> b=[a]
>> >>> a.append("c")
>> >>> b
>> [['a', 'c']]
>>
>> Apperantly, I can change something (which is mutable) inside a list
>> without even touching the list itself :)
>
> But the point is that y
Alan Gauld wrote:
> "Yasar Arabaci" wrote
>
>> >>> a=["a"]
>> >>> b=[a]
>> >>> a.append("c")
>> >>> b
>> [['a', 'c']]
>>
>> Apperantly, I can change something (which is mutable) inside a list
>> without even touching the list itself :)
>
> But the point is that you *are* touching the list.
> In
On Mon, Mar 14, 2011 at 8:56 AM, Alan Gauld wrote:
> "Yasar Arabaci" wrote
>> Apperantly, I can change something (which is mutable) inside a list
>> without even touching the list itself :)
> But the point is that you *are* touching the list.
> In this case you have two names referring to the sa
"Yasar Arabaci" wrote
>>> a=["a"]
>>> b=[a]
>>> a.append("c")
>>> b
[['a', 'c']]
Apperantly, I can change something (which is mutable) inside a list
without even touching the list itself :)
But the point is that you *are* touching the list.
In this case you have two names referring to the
Wow. That was a great explanation indeed. Thanks a lot. After reading
this, I discovered something like this, and found it pretty insteresting
indeed:
>>> a=["a"]
>>> b=[a]
>>> a.append("c")
>>> b
[['a', 'c']]
>>> a.append("d")
>>> b
[['a', 'c', 'd']]
Apperantly, I can change something (which
Yaşar Arabacı wrote:
Author of this post says that we can use mutable variables like this as
static function variables. I was wondering what are mutable variables
and what is rationale behind them.
It sounds like you are reading about Python with the mind-set of a C
programmer. Python is not
"Yasar Arabaci" wrote
exactly like static variables in other languages (as I have used in
php
static in other languages usually refers to variables declared
on the memory heap rather than the stack, and therefore they
retain their value between calls. Python tends to operate at a
higher level
Hi,
As I am starting to learn python, I follow dive into python. As I read
object section, I came across something called class attributes and data
attributes. Because of the reason that class attributes look and behave
exactly like static variables in other languages (as I have used in php
f
10 matches
Mail list logo