Re: [SLUG] Anybody program in Python?

From: R P Herrold (herrold@owlriver.com)
Date: Sun Sep 01 2002 - 13:10:39 EDT


On Sun, 1 Sep 2002, Russell Hires wrote:

> --[PinePGP]--------------------------------------------------[begin]--
> There doesn't seem to be anything that references this that I can find. I
> want to produce a floating point result from the division of two integers,
> but in order to get that result, I have to enter the input as floats as well.
> In other words, 2/5 = 0, but 2.0/5 = .4. There's got to be a way around this
> limitation. I shouldn't have to force the user to enter a decimal point when
> they are inputting numbers.
>
> Anybody have any ideas?

ummm -- do a type cast -- examples are all through the python
codebase:

   grep loat `locate py | grep py$ `

eg:

/home/herrold/dl/Bar/factory.py: 'defCommission': float,

usr/share/doc/PyQt-examples-3.1/gears.py: w = width / float(height)

/usr/share/doc/PyQt-examples-3.1/tut14.py: rad = \
        math.atan(float(self.rect().bottom() - pnt.y()) / pnt.x())



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:30:02 EDT