Re: [Python-3000] Minor addition to Python interactive shell...

2008-08-26 Thread Ron Adam
Abdallah El Guindy wrote: Hey all I know that the feature I am about to suggest may be minor and may have a very low priority considering other issues to be discussed, however I'll suggest it anyways.. Being a very frequent user of the interactive shell, I find it annoying when I try to u

[Python-3000] default argument surprises

2008-08-26 Thread Sam Bishop
Hi, all. I know that Python 3.0 is quite a ways along, but I'd like to make two small suggestions with regards to how the language works. (I would have spoken up earlier, except that I'm very new to Python.) I've talked to a few of my co-workers who are also new to Python, and we've all been sur

Re: [Python-3000] default argument surprises

2008-08-26 Thread Chris Rebert
You might then be interested in the following related discussions from last year wherein I proposed something extremely similar: [Python-ideas] proto-PEP: Fixing Non-constant Default Arguments http://mail.python.org/pipermail/python-ideas/2007-January/000121.html [Python-3000] pre-PEP: Default Ar

Re: [Python-3000] default argument surprises

2008-08-26 Thread Bruce Leban
There are two issues** here: (1) def foo(L=[]): the [] is a single list, not a new list created every time the function is called. (2) def foo(L=list()): the list() is evaluated once when the function is declared. I think (1) is easy to explain; I find (2) confusing. (**Yes, I realize that these

Re: [Python-3000] default argument surprises

2008-08-26 Thread Chris Monson
On Tue, Aug 26, 2008 at 9:10 PM, Bruce Leban <[EMAIL PROTECTED]> wrote: > There are two issues** here: > > (1) def foo(L=[]): > the [] is a single list, not a new list created every time the function is > called. > > (2) def foo(L=list()): > the list() is evaluated once when the function is declar

Re: [Python-3000] default argument surprises

2008-08-26 Thread James Y Knight
On Aug 27, 2008, at 12:14 AM, Chris Monson wrote: Now thinking as a language designer, C# has a ?? operator where A??B is shorthand for (B if A is None else A) except you only have to write A once and A is only evaluated once. A Pythonesque version of this would be just "else": def foo(

Re: [Python-3000] default argument surprises

2008-08-26 Thread Chris Rebert
On Tue, Aug 26, 2008 at 8:31 PM, Chris Rebert <[EMAIL PROTECTED]> wrote: > You might then be interested in the following related discussions from > last year wherein I proposed something extremely similar: > > [Python-ideas] proto-PEP: Fixing Non-constant Default Arguments > http://mail.python.org/

[Python-3000] else Versus or (Was: Re: default argument surprises)

2008-08-26 Thread Eric Astor
Chris Monson wrote: > Now thinking as a language designer, C# has a ?? operator where A??B > is shorthand for (B if A is None else A) except you only have to > write A once and A is only evaluated once. A Pythonesque version of > this would be just "else": > >def foo(arg=No

Re: [Python-3000] default argument surprises

2008-08-26 Thread Bruce Leban
On Tue, Aug 26, 2008 at 9:23 PM, James Y Knight <[EMAIL PROTECTED]> wrote: > On Aug 27, 2008, at 12:14 AM, Chris Monson wrote: > >> >> And I think that metaphor is easy to read. Chains of else operators can be >> useful: >> >> x = f() else g() else h() else 0 >> >> Not a bad idea. Looks like th