"nikhil" wrote
Are objects for arguments, that persist between function calls, created
during function definition ONLY when they have default values ?
In Python the parameters are not objects but names.
names are used to reference objects.
If there is no default value then there is no objec
Le Tue, 26 May 2009 19:42:34 +0530,
nikhil s'exprima ainsi:
> Hi,
>
> Thanks for reply.
>
> I went through the link you provided. It was very helpful.
>
> What I understood is this,
>
> --> Objects are created for default argument types, inside the function
> object.
... for default argument
nikhil wrote:
Hi,
I am learning Python and came across this example in the Python Online
Tutorial (
http://docs.python.org/tutorial/controlflow.html#default-argument-values)
for Default Argument Values.
ex:
def func(a, L=[ ]):
L.append(a)
return L
print func(1)
print func(2)
print func(3)
Hi,
Thanks for reply.
I went through the link you provided. It was very helpful.
What I understood is this,
--> Objects are created for default argument types, inside the function
object. This
happens only once when the function definition statement is executed.
These objects
persist
nikhil wrote:
Hi,
I am learning Python and came across this example in the Python Online
Tutorial
(http://docs.python.org/tutorial/controlflow.html#default-argument-values)
for Default Argument Values.
ex:
def func(a, L=[ ]):
L.append(a)
return L
print func(1)
print func(2)
print func(3)
Hi,
I am learning Python and came across this example in the Python Online
Tutorial (
http://docs.python.org/tutorial/controlflow.html#default-argument-values)
for Default Argument Values.
ex:
def func(a, L=[ ]):
L.append(a)
return L
print func(1)
print func(2)
print func(3)
*O/P*
[1]
[1,2]
[