Hi Chris, Thanks a lot for reply, you are right. I want to use this method as a static method as:
translation = staticmethod( translation ) I think that here the built in function pass None. So we can not pass any self defined object for static method? Best regards, Wei On Wed, Oct 8, 2008 at 5:50 PM, Chris Rebert <[EMAIL PROTECTED]> wrote: > On Wed, Oct 8, 2008 at 4:36 PM, Wei Guo <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I defined a class called vec3 which contains x, y, z and in another > > function, I tried to call a function which takes a vec3 as a parameter, > but > > it seems that parameter is passed as a generic object and I can not > access x > > , y, z in my vec3. Could anyone help me with that? > > Being dynamically typed, Python has no notion of variables having > types, so the object isn't being "passed as a generic object", you're > getting what really is a "generic object" value of type NoneType, > which means the value of traV is indeed None, not vec3(). > > > > > class vec3: > > def __init__(self, x_ = 0.0, y_ = 0.0, z_ = 0.0): > > self.x = x_ > > self.y = y_ > > self.z = z_ > > class mat4: > > def translation( traV = vec3() ): > > tranM.rowLst[index][0] = traV.x > > AttributeError: 'NoneType' object has no attribute 'x' > > This code is perfectly fine. See below. > > > > > Could anyone help me how to turn the traV as type of vec3() instead of > > NoneType object? > > That's not what's happening. It's not like traV is being cast to > NoneType thus making x inaccessible, as that's not even possible to > express in Python. > What's happening is something is calling translation() with None as an > argument, and of course None (the value the caller provided for traV) > has no attribute 'x', hence the error. So, check the full exception > traceback and see who's calling translation() and how the argument > being passed to it got to be None. > > Cheers, > Chris > -- > Follow the path of the Iguana... > http://rebertia.com > > > > > Thanks a lot, > > > > Wei > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > >
-- http://mail.python.org/mailman/listinfo/python-list