I am writing code that needs symbols of which the number is not a priori 
known. To do that, I have used code like this:

    for ind in range(0,2*maxIter+1):
        strSym = 'a' + str(ind) + ' = symbols(\'a_' + str(ind) + '\')'
        exec(strSym, globals())

The code is not easy to read, and in Issue 20825 Oscar Benjamin suggested 
that I use indexed symbols:

"The solution to this in Python is to use lists or tuples or some other 
container rather than raw variables. For example:
x = symbols('x:10')"

Based on that, and 
Core — SymPy 1.7.1 documentation 
<https://docs.sympy.org/latest/modules/core.html?highlight=symbols#sympy.core.symbol.symbols>
 
I am trying to use indexed symbols.

a = symbols('a:2*maxIter+1')

The result is

 (a0*maxIter+1, a1*maxIter+1)

The problem is that symbols does not support variables after the colon, 
defeating the whole purpose of using indexed symbols to begin with.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/da9c162b-1cdb-4be9-8206-bcc6bf2e9c89n%40googlegroups.com.

Reply via email to