Err, is this perhaps a bug that has been fixed since the 0.7.1 release? When I do that, vname can't have commas, else it creates multiple variables:
----- *# For a mnemonic, here is an example variable from a model with which I'm* *# working. The variable format is <VarName>[year, tech, vintage]. * *>>> from sympy import ** *>>> assumptions = dict()* *>>> index = (2010, 'Prius', 2008)* *>>> vname = 'Car[%s]' % ','.join(str(i) for i in index)* * * * # I'm looking to create _single_ variable* *>>> v = symbols( vname, **assumptions )* * * * # but instead I get three* *>>> type( v )* *<type 'tuple'>* *>>> len( v )* *3* *>>> print "Variable 1: '%s'" % v[0]* *Variable 1: 'Car[2010'* *>>> print "Variable 2: '%s'" % v[1]* *Variable 2: 'Prius'* *>>> print "Variable 3: '%s'" % v[2]* *Variable 3: '2008]'* ----- The only way that I currently know how to get a single variable with commas in the name is by updating it's name after it's been created: ----- *>>> v = symbols( 'some_unique_string', **assumptions )* *>>> v.name = vname* *>>> type( v )* *<class 'sympy.core.symbol.Symbol'>* *>>> len( v )* *Traceback (most recent call last):* * File "<stdin>", line 1, in <module>* *TypeError: object of type 'Symbol' has no len()* *>>> print "Variable 4: '%s'" % v* *Variable 4: 'X[2010,Prius,2008]'* ----- Does that help elucidate what I'm asking? What I'm looking for is more direct method to create variables that have names with commas. -- You received this message because you are subscribed to the Google Groups "sympy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/I-qi5iBc8-8J. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
