Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Steven D'Aprano
On Mon, 12 Nov 2012 00:31:53 +, Oscar Benjamin wrote: [...] >>> You were right the first time, Chris. A point that happens to coincide >>> with the arbitrarily chosen origin is no more truthy or falsey than >>> any other. A vector of length 0 on the other hand is a very different >>> beast. >>

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Oscar Benjamin
On 12 November 2012 01:29, Mark Lawrence wrote: > On 12/11/2012 01:18, Oscar Benjamin wrote: >> >> On 12 November 2012 01:10, Mark Lawrence wrote: >>> >>> On 12/11/2012 00:31, Oscar Benjamin wrote: Plain wrong. Vectors are not defined *from any origin*. >>> >>> So when the Captain says

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Roy Smith
In article , Oscar Benjamin wrote: > But then I'm assuming you meant that 245 degrees was a bearing > relative to North. Was it supposed to be relative to my current angle? > Truthfully I wouldn't know what to do without asking the captain a > couple more questions. Granted, this requires some

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Mark Lawrence
On 12/11/2012 01:15, Roy Smith wrote: In article , Mark Lawrence wrote: On 12/11/2012 00:31, Oscar Benjamin wrote: Plain wrong. Vectors are not defined *from any origin*. So when the Captain says "full speed ahead, steer 245 degrees", you haven't the faintest idea where you're going, be

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Mark Lawrence
On 12/11/2012 01:18, Oscar Benjamin wrote: On 12 November 2012 01:10, Mark Lawrence wrote: On 12/11/2012 00:31, Oscar Benjamin wrote: Plain wrong. Vectors are not defined *from any origin*. So when the Captain says "full speed ahead, steer 245 degrees", you haven't the faintest idea where

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Roy Smith
In article , Mark Lawrence wrote: > On 12/11/2012 00:31, Oscar Benjamin wrote: > > > > Plain wrong. Vectors are not defined *from any origin*. > > > > So when the Captain says "full speed ahead, steer 245 degrees", you > haven't the faintest idea where you're going, because you have no origin?

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Oscar Benjamin
On 12 November 2012 01:10, Mark Lawrence wrote: > On 12/11/2012 00:31, Oscar Benjamin wrote: >> >> >> Plain wrong. Vectors are not defined *from any origin*. >> > > So when the Captain says "full speed ahead, steer 245 degrees", you haven't > the faintest idea where you're going, because you have

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Mark Lawrence
On 12/11/2012 00:31, Oscar Benjamin wrote: Plain wrong. Vectors are not defined *from any origin*. So when the Captain says "full speed ahead, steer 245 degrees", you haven't the faintest idea where you're going, because you have no origin? -- Cheers. Mark Lawrence. -- http://mail.python

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Steve Howell
On Nov 11, 4:31 pm, Oscar Benjamin wrote: > On 11 November 2012 22:31, Steven D'Aprano > > Nonsense. The length and direction of a vector is relative to the origin. > > If the origin is arbitrary, as you claim, then so is the length of the > > vector. > > Wrong on all counts. Neither the length n

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Steve Howell
On Nov 10, 11:33 am, Jennie wrote: > What is the best solution to solve the following problem in Python 3.3? > > import math >  >>> class Point: > ...     def __init__(self, x=0, y=0): > ...         self.x = x > ...         self.y = y > ...     def __sub__(self, other): > ...         return Point(

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Oscar Benjamin
On 11 November 2012 22:31, Steven D'Aprano wrote: > On Sun, 11 Nov 2012 14:21:19 +, Oscar Benjamin wrote: > >> On 11 November 2012 02:47, Chris Angelico wrote: >>> On Sun, Nov 11, 2012 at 1:43 PM, Ian Kelly >>> wrote: On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: > I

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Steven D'Aprano
On Sun, 11 Nov 2012 14:21:19 +, Oscar Benjamin wrote: > On 11 November 2012 02:47, Chris Angelico wrote: >> On Sun, Nov 11, 2012 at 1:43 PM, Ian Kelly >> wrote: >>> On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico >>> wrote: I would not assume that. The origin is a point, just like any

Re: Method default argument whose type is the class not yet defined

2012-11-11 Thread Oscar Benjamin
On 11 November 2012 02:47, Chris Angelico wrote: > On Sun, Nov 11, 2012 at 1:43 PM, Ian Kelly wrote: >> On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: >>> I would not assume that. The origin is a point, just like any other. >>> With a Line class, you could deem a zero-length line to be l

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Ian Kelly
On Sat, Nov 10, 2012 at 11:43 PM, Ian Kelly wrote: > Where I wrote "(0,0) is the origin" above I was not referring to a > point, not a tuple, but I can see how that was confusing. What I meant to say is I *was* referring to a point. Gah! -- http://mail.python.org/mailman/listinfo/python-list

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Ian Kelly
On Sat, Nov 10, 2012 at 7:53 PM, Roy Smith wrote: > In article , > Ian Kelly wrote: > >> On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: >> > I would not assume that. The origin is a point, just like any other. >> > With a Line class, you could deem a zero-length line to be like a >> > z

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Roy Smith
In article , Ian Kelly wrote: > On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: > > I would not assume that. The origin is a point, just like any other. > > With a Line class, you could deem a zero-length line to be like a > > zero-element list, but Point(0,0) is more like the tuple (0,0

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 1:43 PM, Ian Kelly wrote: > On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: >> I would not assume that. The origin is a point, just like any other. >> With a Line class, you could deem a zero-length line to be like a >> zero-element list, but Point(0,0) is more like

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Ian Kelly
On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: > I would not assume that. The origin is a point, just like any other. > With a Line class, you could deem a zero-length line to be like a > zero-element list, but Point(0,0) is more like the tuple (0,0) which > is definitely True. It's more

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 12:13 PM, Steven D'Aprano wrote: > Almost but not quite. I assume that, in a full Point class, you would > want Point(0, 0) to count as false in a boolean context. (A "falsey" > value, like None, [], 0.0, etc.) I would not assume that. The origin is a point, just like any

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Oscar Benjamin
On 10 November 2012 19:33, Jennie wrote: > What is the best solution to solve the following problem in Python 3.3? > > import math class Point: > ... def __init__(self, x=0, y=0): > ... self.x = x > ... self.y = y > ... def __sub__(self, other): > ... return Po

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Steven D'Aprano
On Sat, 10 Nov 2012 20:33:05 +0100, Jennie wrote: [...] > I propose three solutions. The first one: > > >>> class Point: > ... def __init__(self, x=0, y=0): > ... self.x = x > ... self.y = y > ... def __sub__(self, other): > ... return Point(self.x - other.x, self

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Dave Angel
On 11/10/2012 03:51 PM, Jennie wrote: > On 11/10/2012 09:29 PM, Terry Reedy wrote: > >> On 11/10/2012 2:33 PM, Jennie wrote: >>> >>> I propose three solutions. The first one: >>> >>> >>> class Point: >>> ... def __init__(self, x=0, y=0): >>> ... self.x = x >>> ... self.y = y >>

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Jennie
On 11/10/2012 09:29 PM, Terry Reedy wrote: On 11/10/2012 2:33 PM, Jennie wrote: I propose three solutions. The first one: >>> class Point: ... def __init__(self, x=0, y=0): ... self.x = x ... self.y = y ... def __sub__(self, other): ... return Point(self.x - o

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Terry Reedy
On 11/10/2012 2:33 PM, Jennie wrote: What is the best solution to solve the following problem in Python 3.3? import math >>> class Point: ... def __init__(self, x=0, y=0): ... self.x = x ... self.y = y ... def __sub__(self, other): ... return Point(self.x - other

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 6:33 AM, Jennie wrote: > ... def distance(self, point=None): > ... p = point if point else Point() I'd go with this one. Definitely not the third one, which mutates the class according to a current global every time a Point is instantiated - could be *extremely