[SciPy-User] TypeError

josef.pktd@gmai... josef.pktd@gmai...
Thu Oct 21 08:16:48 CDT 2010


On Thu, Oct 21, 2010 at 6:22 AM, Waléria Antunes David <
waleriantunes@gmail.com> wrote:

> Hi all,
>
> I have this code: http://pastebin.com/nDrisnhZ
> and my forms.py: http://pastebin.com/wHEErcQx
>
> But is ocurring this error:
>
> TypeError at /index/
>
> unsupported operand type(s) for ** or pow(): 'Decimal' and 'float'
>
>  Request Method: POST  Request URL: http://localhost:8000/index/  Exception
> Type: TypeError  Exception Value:
>
> unsupported operand type(s) for ** or pow(): 'Decimal' and 'float'
>
>  Exception Location: C:\supernovas_Ia\..\supernovas_Ia\supernovas\views.py
> in index, line 19
>

as your exception says fractional powers are not supported for Decimal type,
you need to convert/cast it

>>> Decimal(532, 2)**(0.5)
Traceback (most recent call last):
  File "<pyshell#129>", line 1, in <module>
    Decimal(532, 2)**(0.5)
TypeError: unsupported operand type(s) for ** or pow(): 'Decimal' and
'float'
>>> float(Decimal(532, 2))**(0.5)
23.065125189341593

As someone mentioned before, trying it in an interpreter shell is easier.

Josef


>
> How do i fix this?
>
> Thanks,
> Waléria
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20101021/fb9fd5a2/attachment.html 


More information about the SciPy-User mailing list