On Thu, Sep 25, 2008 at 6:06 PM, Robert Bradshaw
<[EMAIL PROTECTED]> wrote:
>
>
> On Sep 25, 2008, at 5:43 PM, William Stein wrote:
>
>>
>> On Thu, Sep 25, 2008 at 5:33 PM, Quicksilver_Johny
>> <[EMAIL PROTECTED]> wrote:
>>>
>>> If c=sqrt(a^2+b^2)
>>> How would I check if c is an integer in order to get a true/false
>>> value.
>>> I tried is_Integer(ZZ(c)), this returns true when c is an integer,
>>> but
>>> ZZ(c) returns an error when c is not an integer.
>>
>> Try using Python's try/except:
>>
>> try:
>>     ZZ(c)
>>     # c is an integer
>> except TypeError:
>>     # c isn't an integer
>
> These is_* sure are causing a lot of confusion lately...

Indeed!  I like Mike Hansen's (or your) proposal to get
rid of them all from the global namespace, and replace
them only by "is_lowercase_method_name" functions
that are all conceptually meaningful.   Of course leave
the type-checking is_Uppercase's around, but don't
put them in all.py's.

What do you guys think?

>
> Rational numbers also have an is_integral method, so you could also dos
>
> c=sqrt(a^2+b^2)

If a,b are integers, then c is either an integer or an element
of the symbolic ring...

> if c.is_integral():
>    # c is an integer
>
> - Robert
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to