On 12/6/05, Alan Gauld <[EMAIL PROTECTED]> wrote:
> Lots of good stuff from Wes snipped...
> > (a side note here: that only mutable objects have methods.)
>
> But this is not quite true. Strings are immutable and have lots
> of methods and even tuples and plain integers have methods
oh POO. i *
Lots of good stuff from Wes snipped...
> (a side note here: that only mutable objects have methods.)
But this is not quite true. Strings are immutable and have lots
of methods and even tuples and plain integers have methods
(albeit Pythons magic operator methods) which can be
subclassed and o
Thanks for your valuable feedback guys.
Cheers
Hans
-Original Message-
From: w chun [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 6 December 2005 9:11 p.m.
To: Hans Dushanthakumar
Cc: tutor@python.org
Subject: Re: How to Pass lists by value
On 12/5/05, Kent Johnson <[EMAIL PROTECTED]> wrote
On 12/5/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> You have to change how you think about variables. In Python, a variable
> is not a storage location into which values are put, it is a reference
> to an object - a name given to an object. Assignment binds a name to a
> value.
>
> When you cal
s important to understand
namespaces :-)
This may help:
http://effbot.org/zone/python-objects.htm
Kent
>
>
>
> *From:* Adam [mailto:[EMAIL PROTECTED]
> *Sent:* Tuesday, 6 December 2005 1:49 p.m.
> *To:* Hans Dushanthakumar
> *Subject:* Re: [Tu
On 06/12/05, Hans Dushanthakumar <[EMAIL PROTECTED]> wrote:
>
> Thanks guys
>
> Yes either of the foll solves the problem:
>
> b = junk(copy.copy(a))
>
> OR
>
> b = junk(a[:])
One thing you should be aware of --- these will both do a "shallow copy".
Example:
>>> lists = [[], [], [], []]
>>> lis
Tuesday, 6 December 2005 1:49 p.m.To: Hans
DushanthakumarSubject: Re: [Tutor] How to Pass lists by
value
On 06/12/05, Hans Dushanthakumar <[EMAIL PROTECTED]>
wrote:
Hi
folks, How do I pass a list by value to a function.The
foll: snippet of code produces the output as
sho
Hi folks,
How do I pass a list by value to a function.
The foll: snippet of code produces the output as shown:
Code:
-
def junk(x):
x.append("20")
return x
a = ["10"]
b = junk(a)
print b
print a
Output:
---
>>>
b = ['10', '20']
a = ['10', '20']
This indicates that the