# Revision history [back]

### Help to understand an AttributeError in a polynomial ring

F. Chapoton recently wrote a program the behaviour of which I do not understand.

def fermat(n):
q = polygen(ZZ, 'q')
return sum(n ** j * binomial(n, j) * (-1) ** (i + n + j) *
binomial(n - 2 - j + 1, i + 1) * q ** i
for j in range(n - 1)
for i in range(n - 1 - j))


Now consider:

v = fermat(5)
print v.parent()
print v.list()


This outputs

Univariate Polynomial Ring in q over Integer Ring
[821, 181, 21, 1]


which is fine. However the loop

for n in (1..9):
v = fermat(n)
print v.parent()
print v.list()


gives the errors:

AttributeError: 'int' object has no attribute 'parent'
AttributeError: 'int' object has no attribute 'list'


What happens here?