If I call
print walk([1,2,3], [])
print walk([5,6,7])
I get
[1, 2, 3]
[4, 5, 6]
but when I call
print walk([1,2,3])
print walk([5,6,7])
I get
[1, 2, 3]
[1, 2, 3, 4, 5, 6]
at stdout, where
def walk(seq, result = []):
for item in seq:
result.append(item)
return result
Does that mean that the scope of optional arguments is global if they aren't
used and local if they are (or am I missing something here)?
Regards,
CS 3 851 http://www.ferg.org/projects/python_...ontents_item_6
On Mon, May 19, 2008 at 10:30 AM, cseja <p5*****@uni-jena.dewrote:
If I call
print walk([1,2,3], [])
print walk([5,6,7])
I get
[1, 2, 3]
[4, 5, 6]
but when I call
print walk([1,2,3])
print walk([5,6,7])
I get
[1, 2, 3]
[1, 2, 3, 4, 5, 6]
at stdout, where
def walk(seq, result = []):
for item in seq:
result.append(item)
return result
Does that mean that the scope of optional arguments is global if they aren't
used and local if they are (or am I missing something here)?
Regards,
CS
-- http://mail.python.org/mailman/listinfo/python-list
Whoops, I meant to call
print walk([1,2,3], [])
print walk([4,5,6])
and
print walk([1,2,3])
print walk([4,5,6])
with
def walk(seq, result = []):
for item in seq:
result.append(item)
return result
The question is still the same: Why do both calls give different results?
Thank you very much for reading, I'm sorry for the inconvenience.
Thank you very much for your fast and usefull response, Steven. Have a nice
day. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JT |
last post by:
how can i declare a function that will accept an optional parameter?
something like:
function newFunc(strValue1, strValue2) --where strValue2 is optional.
thanks much.
|
by: cody |
last post by:
I got a similar idea a couple of months ago, but now this one will require
no change to the clr, is relatively easy to implement and would be a great
addition to C# 3.0 :)
so here we go..
To...
|
by: Rob Hoelz |
last post by:
So these two functions are different:
void foo(void);
and
void foo();
because the first one allows no arguments, but the second does. My
question is: In the implementation of the...
|
by: MMcCarthy |
last post by:
We often get questions on this site that refer to the scope of variables and where and how they are declared. This tutorial is intended to cover the basics of variable scope in VBA for MS Access. For...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |