Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 1977 by dlenski: symbols() gives unexpected behavior when passed
a list of length 1
http://code.google.com/p/sympy/issues/detail?id=1977
It makes sense for symbols() to return a single Symbol object when passed a
single positional argument:
a, b, c = symbols("a", "b", "c")
a = symbols("a")
# NOT: a, = symbols("a")
However, this behavior doesn't really make sense when passed a dynamically
generated list as its first argument:
symbol_names = ["a", "b", "c"]
my_symbols = symbols(symbol_names) # WORKS!
print my_symbols[0] # prints "a"
symbol_names = ["x"]
my_symbols = symbols("x") # returns a SINGLE SYMBOL
# rather than a length 1 list
print my_symbols[0] # ERROR!
This introduces weird bugs in code when you don't know how many symbols
you're creating.
I'm writing some code that dynamically generates symbolic objects, and this
has bitten me several times!
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
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-issues?hl=en.