Python

Jp Calderone exarkun at intarweb.us
Fri Feb 7 13:23:58 EST 2003


On Thu, Feb 06, 2003 at 07:46:34PM -0800, Paul Rubin wrote:
> phrogeeb at hotmail.com (Uri) writes:
> > Ok, so Python vets I bet are already seeing what my problem is. I ask
> > for the numbers with the syntax:     r = input("r?")
> > 
> > My problem is that r is a percentage (in my program, I tell the user
> > to represent 4% as .04).  When I run the program, it says that there's
> > no way to deal with a double or something to that effect. But I also
> > read that there's no way to type a variable, that they are
> > "dynamically typed". Well, that doesn't work here.
> 
> The problem is the input function returns a string, not a float.

  No.

    >>> isinstance(input('Prompt: '), str)
    Prompt: 50
    0

> 
> Also, you should use raw_input rather than input, to get exactly
> what the user types.  So you'd write your example
> 
>     r = float(raw_input("r? "))

  I have trouble recounciling this part of your message with the above claim
you make ;)

  Jp

-- 
There are 10 kinds of people: those who understand binary and those who do
not.
-- 
 up 53 days, 21:50, 7 users, load average: 0.16, 0.25, 0.22
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030207/f1791c56/attachment.sig>


More information about the Python-list mailing list