The function print
prints its argument and returns None
,
which is the closest in Python to “not returning anything”.
When the return value of a command is None
, it does not
get displayed. Here however you are building a list
of these return values, so you get a list all of whose
elements are None
, and that list does get displayed.
To avoid that, use a for loop without building a list.
sage: A = GF(7)
sage: for i in A:
....: print(i)
....:
0
1
2
3
4
5
6
Starting from a polynomial ring with variable x
,
and taking a quotient, Sage uses xbar
as the
default name for the image of the variable x
in the quotient.
To choose a different name:
sage: R.<x> = PolynomialRing(Zmod(3))
sage: A.<t> = R.quotient(x^2)
sage: for i in A:
....: print(i)
sage: R.<x> = PolynomialRing(Integers(3))
sage: A.<t> = R.quotient(x^2)
sage: for i in A:
....: print(i)
....:
0
1
2
t
t + 1
t + 2
2*t
2*t + 1
2*t + 2
One can also use x
for the variable name in the quotient:
sage: R.<x> = PolynomialRing(Zmod(3))
sage: A.<x> = R.quotient(x^2)
sage: for i in A:
....: print(i)
....:
0
1
2
x
x + 1
x + 2
2*x
2*x + 1
2*x + 2
If you want a one-liner rather than a full-blown print loop,
you can use consume
from the more_itertools package
(which you first have to install using pip).
sage: %pip install more_itertools
...
sage: from more_itertools import consume
sage: consume(print(i) for i in A)
0
1
2
x
x + 1
x + 2
2*x
2*x + 1
2*x + 2
Read more here: Source link