Difficulty with sagetex
Please forgive any short comings as I am new to sage, python and sagetex, perhaps I'm trying to run before I can walk or even crawl!
I am trying to run the the sageblock below to obtain the sequence 'S' and reference individual elements of the list 'S'. It works fine in Sage but cannot get any where with sagetex.
\begin{sagesilent}
def nmax(max=100):
n = 1
an = 20
while n <= max:
yield an
n += 1
an = 0.9*an-5
a = nmax(30)
S=[]
for i in a:
S.append(i.n())
\end{sagesilent}
produces the error
** Error in Sage code on line 36 of sequences01.tex! Traceback follows. Traceback (most recent call last):
File "sequences01.sagetex.py", line 43, in <module> _st_.inline(_sage_const_3 , latex(S)) NameError: name 'S' is not defined
When I try to access 'S' with $\sage{S}$
, am beginning to feel at a loss as to where to look now.
Many thanks kcrisman, works for me too now! Am going to have to study the indentation a bit more when typing into sagetex. Thanks a lot for your speedy response.
No problem! Basically, just use four spaces after a colon. Going through one of the (many) Python tutorials out there wouldn't be a bad place to start.
Thanks again, went over a Python tutorial again and got to grips with indentation and a after a little experimentation found the 4 spaces for myself and all going well now! Thanks.
By the way, I think Python actually accepts any consistent indentation, not just four spaces - but that is certainly the most common practice and easiest to read. You may be able to set up your editor to do this automatically after colons.