Hi Grant,
I am using the try/exception and just curious why function type doesn't
work.
Best regards,
Wei
On 8/7/08, Timothy Grant <[EMAIL PROTECTED]> wrote:
>
> That's because s IS a string. It's not been converted to a float.
>
> In [1]: s = '3.1415'
> In [2]: n = float(s)
> In [3]: type(s)
That's because s IS a string. It's not been converted to a float.
In [1]: s = '3.1415'
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]> wr
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 <[EMAIL PROTECTED]> wrote:
>
> Hi Thanks for Tyler and Edwin's help.
>
Hi Thanks for Tyler and Edwin's help.
For my questions, I need to import some xml file and there are floating
number and strings in it. I need to process string and number differently.
This is reason that I am asking question here. Is this background
information we need for this quesions.
Btw, wh
It's generally a bad idea to use "except" without naming a specific
exception. The exception you might expect in this case is ValueError.
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') wi
ect: RE: A question about string and float number
type(s) == type(float())
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Wei Guo
Sent: Wednesday, August 06, 2008 9:23 PM
To: python-list@python.org
Subject: A question about string and float number
Hi all,
I
type(s) == type(float())
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Wei Guo
Sent: Wednesday, August 06, 2008 9:23 PM
To: python-list@python.org
Subject: A question about string and float number
Hi all,
I am new of python. Could anyone help me a quest