Doesn't know what it wants

Steven D'Aprano steve at
Sat Jan 26 08:25:25 CET 2008

On Fri, 25 Jan 2008 22:53:16 -0800, John Machin wrote:

> On Jan 26, 5:32 pm, Jeroen Ruigrok van der Werven <asmo... at in-
>> wrote:
>> -On [20080126 06:26], Tim Rau (bladedpeng... at wrote:
>> >Line 147 reads:
>> >        moi = cp.cpMomentForCircle(self.mass, .2, 0, vec2d((0,0)))
>> I think it expects something like:
>> # badly named variable, pick something better depending on context 
>> temp = vec2d(0, 0)
>> cp.cpMomentForCircle(self.mass, .2, 0, temp)
> That *cannot* give a different result in Python. The called function
> will be presented with *exactly* the same object as the OP's code does.

Not quite. Look carefully at the difference.

The OP's code calls vec2d with a single tuple argument (0,0). Jeroen's 
version calls vec2d with two int arguments, 0 and 0.

We don't know whether vec2d will treat those two things the same or not.

Personally, my bet is that the OP has shadowed vec2d, and has got two 
different classes floating around with the same class.__name__.

Either that, or a bug in cp.cpMomentForCircle. I'd really like to see the 
code of that function in phyInit. I'm suspicious about the exception 

ArgumentError: argument 4: <type 'exceptions.TypeError'>: expected vec2d 
instance instead of vec2d

What's with the TypeError in there? I'm guessing it's not a hard coded 


More information about the Python-list mailing list