For the bug, in the following example proposed by Vegrad LIma, the 1st and last line look contradictory in a dynamical language.
*sage: a = var('a') sage: a.is_real() False* sage: assume(a,"real") sage: a.is_real() False sage: a = var('a',domain='real') sage: a.is_real() True sage: a = 2+2*I sage: a.is_real() False *sage: a = var('a') sage: a.is_real() True* *Christophe BAL* *Enseignant de mathématiques en Lycée **et développeur Python amateur* *---* *French math teacher in a "Lycée" **and **Python **amateur developer* 2015-01-29 23:55 GMT+01:00 William Stein <wst...@gmail.com>: > On Thu, Jan 29, 2015 at 4:58 AM, Christophe Bal <projet...@gmail.com> > wrote: > > Thanks for the argument domain. > > > > For the end of the code, this sounds like a bug. > > No -- I thought somebody would answer, but nobody did. The following > is definitely *not* a bug: > > >> sage: a = 2+2*I > >> sage: a.is_real() > >> False > > What's happening here is that you assign a 2+2*I, which is complex. > At this point the variable a in Python is a reference to the symbolic > expression 2+2*I. It has absolutely nothing whatsoever to do with > what a was equal to when you typed: > > >> sage: a = var('a',domain='real') > >> sage: a.is_real() > >> True > > This is because Python is a *dynamically* typed language. Thinking > that doing something like > > a = var('a',domain='real') > > would have any impact on what > > a = BLAH > > means would only make sense in a statically typed programming > language, such as C++ or Java. > > -- William > > > > > > > > > > > Christophe BAL > > Enseignant de mathématiques en Lycée et développeur Python amateur > > --- > > French math teacher in a "Lycée" and Python amateur developer > > > > 2015-01-29 13:04 GMT+01:00 Vegard Lima <vegard.l...@gmail.com>: > >> > >> Hi, > >> > >> On Thu, Jan 29, 2015 at 12:33 PM, Christophe Bal <projet...@gmail.com> > >> wrote: > >> > I've just tried > >> > > >> > a = var("a") > >> > assume(a, "real") > >> > > >> > print a.is_real() > >> > > >> > This prints False. Why ? > >> > >> I can't answer why, but an option is to use > >> var('a',domain='real') > >> but that seems to behave a bit strangely: > >> > >> sage: a = var('a') > >> sage: a.is_real() > >> False > >> > >> sage: assume(a,"real") > >> sage: a.is_real() > >> False > >> > >> sage: a = var('a',domain='real') > >> sage: a.is_real() > >> True > >> > >> sage: a = 2+2*I > >> sage: a.is_real() > >> False > >> > >> sage: a = var('a') > >> sage: a.is_real() > >> True > >> > >> > >> Cheers, > >> -- > >> Vegard Lima > >> > >> -- > >> 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 sage-support+unsubscr...@googlegroups.com. > >> To post to this group, send email to sage-support@googlegroups.com. > >> Visit this group at http://groups.google.com/group/sage-support. > >> For more options, visit https://groups.google.com/d/optout. > > > > > > -- > > 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 sage-support+unsubscr...@googlegroups.com. > > To post to this group, send email to sage-support@googlegroups.com. > > Visit this group at http://groups.google.com/group/sage-support. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > William Stein > Professor of Mathematics > University of Washington > http://wstein.org > > -- > 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 sage-support+unsubscr...@googlegroups.com. > To post to this group, send email to sage-support@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-support. > For more options, visit https://groups.google.com/d/optout. > -- 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 sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.