Re: whassup? builtins? python3000? Naah can't be right?

2010-01-31 Thread Terry Reedy
On 1/31/2010 4:17 PM, _wolf wrote: but why does ``__builtins__`` change its meaning depending on whether this is the scope of the ‘script’ (i.e. the module whose name was present, when calling ``python foobar.py``) or whether this is the scope of a secondary module (imported or executed, directl

Re: Python and Ruby

2010-01-31 Thread John Bokma
Steven D'Aprano writes: > On Sun, 31 Jan 2010 18:47:42 -0600, John Bokma wrote: > >> Steven D'Aprano writes: >> >>> On Sun, 31 Jan 2010 14:47:08 -0600, John Bokma wrote: >>> An editor can correct the indenting of the braces example but can't with this one. if x:

Re: Python and Ruby

2010-01-31 Thread Terry Reedy
On 1/31/2010 7:25 PM, Steven D'Aprano wrote: On Sun, 31 Jan 2010 15:40:36 -0800, Chris Rebert wrote: On Sun, Jan 31, 2010 at 2:36 PM, Steven D'Aprano wrote: On Sun, 31 Jan 2010 04:28:41 -0800, Ed Keith wrote: In most functional languages you just name a function to access it and you do it A

Re: odd drawing problem with turtle.py

2010-01-31 Thread John Posner
> I'm on Python 2.5, but using the updated turtle.py Version 1.0.1 - 24. 9. 2009. > The following script draws 5 circles, which it is supposed to, but then > doesn't draw the second turtle which is supposed to simply move forward. > Any ideas? Try commenting out this statement: self.turtle.t

Re: Python and Ruby

2010-01-31 Thread Paul Rubin
Terry Reedy writes: > Three of you gave essentially identical answers, but I still do not > see how given something like > > def f(): return 1 > > I differentiate between 'function object at address xxx' and 'int 1' > objects. In the languages they are talking about, there is no such thing as a f

Re: odd drawing problem with turtle.py

2010-01-31 Thread Alf P. Steinbach
* John Posner: > I'm on Python 2.5, but using the updated turtle.py Version 1.0.1 - 24. 9. 2009. > The following script draws 5 circles, which it is supposed to, but then > doesn't draw the second turtle which is supposed to simply move forward. > Any ideas? Try commenting out this stateme

Re: [Edu-sig] odd drawing problem with turtle.py

2010-01-31 Thread kirby urner
On Sun, Jan 31, 2010 at 8:07 PM, Vern Ceder wrote: > kirby urner wrote: >> >> I don't see where you've defined a Turtle class to instantiate sir. > > The Turtle class is part of the turtle library, so that's not an issue. > Hey, good point Vern, not firing on all cylinders over here. So I just c

A performance issue when using default value

2010-01-31 Thread keakon
I've found strange performance issue when using default value, the test code is list below: from timeit import Timer def f(x): y = x y.append(1) return y def g(x=[]): y = [] y.append(1) return y def h(x=[]): y = x y.append(1) return y def f2(x): y = x y.append(1) return

Re: A performance issue when using default value

2010-01-31 Thread alex23
keakon wrote: > def h2(x=[]): >   y = x >   y.append(1) >   return y + [] > h2() is about 42 times slower than h2([]), but h() is a litter faster > than h([]). Are you aware that 'y = x' _doesn't_ make a copy of [], that it actually points to the same list as x? My guess is that the slowdown yo

Re: A performance issue when using default value

2010-01-31 Thread Chris Rebert
On Sun, Jan 31, 2010 at 8:58 PM, keakon wrote: > I've found strange performance issue when using default value, the > test code is list below: > > from timeit import Timer > > def f(x): >  y = x >  y.append(1) >  return y > > def g(x=[]): >  y = [] >  y.append(1) >  return y > > def h(x=[]): >  y

Re: A performance issue when using default value

2010-01-31 Thread alex23
alex23 wrote: > keakon wrote: > > def h2(x=[]): > >   y = x > >   y.append(1) > >   return y + [] > > Are you aware that 'y = x' _doesn't_ make a copy of [], that it > actually points to the same list as x? Sorry, I meant to suggest trying the following instead: def h2(x=None): if x is None:

Re: A performance issue when using default value

2010-01-31 Thread keakon
On 2月1日, 下午1时20分, alex23 wrote: > alex23 wrote: > > keakon wrote: > > > def h2(x=[]): > > > y = x > > > y.append(1) > > > return y + [] > > > Are you aware that 'y = x' _doesn't_ make a copy of [], that it > > actually points to the same list as x? > > Sorry, I meant to suggest trying the

Re: A performance issue when using default value

2010-01-31 Thread alex23
keakon wrote: > The default value is mutable, and can be reused by all each call. > So each call it will append 1 to the default value, that's very > different than C++. Being different from C++ is one of the many reasons some of us choose Python ;) This tends to bite most newcomers, so it's men

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 20:22:36 -0800, Paul Rubin wrote: > Terry Reedy writes: >> Three of you gave essentially identical answers, but I still do not see >> how given something like >> >> def f(): return 1 >> >> I differentiate between 'function object at address xxx' and 'int 1' >> objects. > > In

Re: A performance issue when using default value

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 20:58:50 -0800, keakon wrote: > I've found strange performance issue when using default value, the test > code is list below: > > from timeit import Timer > > def f(x): > y = x > y.append(1) > return y > > def g(x=[]): > y = [] > y.append(1) > return y > > def h

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 18:53:16 -0600, John Bokma wrote: > You don't have to buy my argument, I am not selling it. It's a figure of speech. You are making an argument others have made before, and I don't accept the validity of the argument. -- Steven -- http://mail.python.org/mailman/listinfo/p

Re: Python and Ruby

2010-01-31 Thread Paul Rubin
Steven D'Aprano writes: > How would Haskell coders write it? Something like this? > > def get_popular_name(url): > data = fetch url > names = parse data > name = choose name 1 > return name The syntax and types would be different, but ok, something like that. > name = get_popular

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 21:30:15 -0600, John Bokma wrote: > While braces might be considered redundant they are not when for one > reason or another formatting is lost or done incorrectly. I've heard this argument before, and I don't buy it. Why should we expect the editor to co

Re: Python and Ruby

2010-01-31 Thread alex23
Steven D'Aprano wrote: > You're using that term wrong. It looks to me that you don't actually know > what a straw man argument is. A straw man argument is when somebody > responds to a deliberately weakened or invalid argument as if it had been > made by their opponent. Jeez, Steve, you're beginn

Re: Python and Ruby

2010-01-31 Thread Chris Rebert
On Sun, Jan 31, 2010 at 10:05 PM, Steven D'Aprano wrote: > On Sun, 31 Jan 2010 20:22:36 -0800, Paul Rubin wrote: >> Terry Reedy writes: >>> Three of you gave essentially identical answers, but I still do not see >>> how given something like >>> >>> def f(): return 1 >>> >>> I differentiate betwee

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 22:43:56 -0800, alex23 wrote: > Steven D'Aprano wrote: >> You're using that term wrong. It looks to me that you don't actually >> know what a straw man argument is. A straw man argument is when >> somebody responds to a deliberately weakened or invalid argument as if >> it had

Re: Python and Ruby

2010-01-31 Thread Paul Rubin
Chris Rebert writes: > get_popular_name would have the type: IO () -> IO String I don't know if it makes the explanation any clearer, but I think that isn't quite right. The Python version would have type String -> IO String. The parameterless Haskell version would just be an I/O action, with

<    1   2