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 ros...@gmail.com wrote: On Sun, Nov 11, 2012 at 1:43 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico ros...@gmail.com wrote: I would not assume that. The origin is a point, just like any other. With a Line

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 ros...@gmail.com wrote: On Sun, Nov 11, 2012 at 1:43 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico ros...@gmail.com wrote: I would not assume

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 steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 11 Nov 2012 14:21:19 +, Oscar Benjamin wrote: On 11 November 2012 02:47, Chris Angelico ros...@gmail.com wrote: On Sun, Nov 11, 2012 at 1:43 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Sat,

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 namedotpor...@gmail.com 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): ...        

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 oscar.j.benja...@gmail.com 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.

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. --

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 breamore...@yahoo.co.uk 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

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

2012-11-11 Thread Roy Smith
In article mailman.3570.1352682390.27098.python-l...@python.org, Mark Lawrence breamore...@yahoo.co.uk 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

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 breamore...@yahoo.co.uk 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

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 mailman.3570.1352682390.27098.python-l...@python.org, Mark Lawrence breamore...@yahoo.co.uk 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

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

2012-11-11 Thread Roy Smith
In article mailman.3571.1352683098.27098.python-l...@python.org, Oscar Benjamin oscar.j.benja...@gmail.com 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

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 breamore...@yahoo.co.uk wrote: On 12/11/2012 01:18, Oscar Benjamin wrote: On 12 November 2012 01:10, Mark Lawrence breamore...@yahoo.co.uk wrote: On 12/11/2012 00:31, Oscar Benjamin wrote: Plain wrong. Vectors are not defined *from any origin*. So

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. Nonsense.

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 namedotpor...@gmail.com 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

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 -

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 -

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 ... def __sub__(self,

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.y -

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 namedotpor...@gmail.com 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): ...

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 steve+comp.lang.pyt...@pearwood.info 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

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 ros...@gmail.com 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

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 ian.g.ke...@gmail.com wrote: On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico ros...@gmail.com 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

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

2012-11-10 Thread Roy Smith
In article mailman.3549.1352601828.27098.python-l...@python.org, Ian Kelly ian.g.ke...@gmail.com wrote: On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico ros...@gmail.com wrote: I would not assume that. The origin is a point, just like any other. With a Line class, you could deem a

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 r...@panix.com wrote: In article mailman.3549.1352601828.27098.python-l...@python.org, Ian Kelly ian.g.ke...@gmail.com wrote: On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico ros...@gmail.com wrote: I would not assume that. The origin is a point,

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 ian.g.ke...@gmail.com 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! --