Its bad practice in Python to depend explicitly on the specific type. You 
should implement your algorithm such that it does not matter if the type is 
exactly a Sage integer or just something that behaves like an integer:

try:
    ... do something ...
except ValueError:
    ... not an integer? ...

The second-best solution is to see if it is something that can be converted 
into ZZ:

sage: 5 in ZZ
True
sage: 5/2 in ZZ
False

The worst solution is to look directly at the type:

sage: isinstance(5, sage.rings.integer.Integer)
True


On Wednesday, May 1, 2013 12:33:16 PM UTC+1, Abhishek Kumar wrote:
>
> Hello All, 
>
> I am a new user of SAGE. I need to know how to control flow of how to 
> control execution according to data type. As in a given loop I want to 
> execute loop further only if variable is of a integer type. 
>
>
> On Tue, Apr 23, 2013 at 9:51 PM, Felix Wellen 
> <[email protected]<javascript:>
> > wrote:
>
>> With "backend='ppl', base_ring=QQ" it works!
>>
>> Thanks again ;)
>>
>> Am Dienstag, 23. April 2013 14:10:26 UTC+2 schrieb Volker Braun:
>>>
>>> This is now http://trac.sagemath.org/14479 (needs review)
>>>
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sage-support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/sage-support?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to