A question about funcation parameter and self defined object

2008-10-08 Thread Wei Guo
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? class vec3: def

Re: A question about funcation parameter and self defined object

2008-10-08 Thread Wei Guo
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

Re: A question about funcation parameter and self defined object

2008-10-09 Thread Wei Guo
TED]> wrote: > Wei Guo wrote: > >> Hi Chris, >> Thanks a lot for reply, you are right. I want to use this method as a >> static method as: >> translation = staticmethod( translation ) >> > > static methods are mostly useless in Python. Just put the

A question about string and float number

2008-08-06 Thread Wei Guo
Hi all, I am new of python. Could anyone help me a question as below? Is there any function that can judge a string s is a float number or not? FOr example, if s = '1.232' or s='1e+10', then it returns true, otherwise, it will return false. isdigit() in string doesn't work. float() will throw an

Re: A question about string and float number

2008-08-07 Thread Wei Guo
rror. Any > other exception *should* be uncaught if it happens. By the way, this method > will return true for integers as well as floats. For example, isFloat('3') > will return 3.0. So make sure this is what you want, since it wasn't 100% > clear from the original message

Re: A question about string and float number

2008-08-07 Thread Wei Guo
Hi I tried the first type method but it seens that it doesn't work. Could anyone help me about it? >>> s = '3.145' >>> type(s) == type(float()) False >>> type(s) >>> type(float()) >>> Best regards, Wei On 8/7/08, Wei Guo <[EM

Re: A question about string and float number

2008-08-07 Thread Wei Guo
27; > In [2]: n = float(s) > In [3]: type(s) > Out[3]: > In [4]: type(n) > Out[4]: > > Why are you avoiding the very simple try:/except: solution to this problem? > > On Thu, Aug 7, 2008 at 1:28 PM, Wei Guo <[EMAIL PROTECTED]> wrote: > > Hi I tried the firs