Hi! On 2013-05-20, man...@gmx.net <man...@gmx.net> wrote: > import bar > type( bar.foo( ) ) > > returns > ><type 'int'> > > Needless to say, this causes a bunch of new errors if my code assumes > that I get a sage type (I came across this because I did something like > real( ) on the result). > > Is this expected behaviour?
Yes. If you import a Python module, then it is the expected behaviour that you get a Python <int> and not a Sage Integer. In interactive sessions (command line or notebook) and when you attach a .sage-file, then a preparser comes into play. For example: sage: preparse('1') 'Integer(1)' sage: preparse('f(x) = x^2') '__tmp__=var("x"); f = symbolic_expression(x**Integer(2)).function(x)' sage: preparse('R.<x,y> = QQ[]') "R = QQ['x, y']; (x, y,) = R._first_ngens(2)" So, typing "1" in an interactive session results in a Sage Integer *only* because the preparser makes it so. Similarly, the preparser makes it possible to define a symbolic function or a polynomial ring in a nice syntax. But when you write a Python module then there is no preparser. Hence, you need to adhere to Python syntax. Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.