# Did SymPy change the syntax?

**URL:** <https://discourse.julialang.org/t/did-sympy-change-the-syntax/30007>\
**Category:** General Usage\
**Created:** [October 17, 2019, 3:48am UTC](https://discourse.julialang.org/t/did-sympy-change-the-syntax/30007 "2019-10-17T03:48:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marouane](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marouane/32/16267_2.png) [@marouane](https://discourse.julialang.org/u/marouane)\
**Post date:** [October 17, 2019, 3:48am UTC](https://discourse.julialang.org/t/did-sympy-change-the-syntax/30007/1 "2019-10-17T03:48:58Z")

</div>

i have this function where i’m using PyCall and SymPy:

```julia
using SymPy
using PyCall
function op_mat(op)
    op = op[:as_poly](domain="C") # return the input as a polynom
    op_a = op.x[:gens] # give us the generators of the polynom for example x and y
    nab = op[:length]()
    op_ab = ones(SymPy.Sym, nab)
    coef = zeros(Complex, nab)
    mat = zeros(Int64, length(op_a), nab)
    for (i, (ps, c)) in enumerate(op[:as_dict]())
        for (j, p) in enumerate(ps)
            mat[j, i] = p
            op_ab[i] = op_a[j]^p * op_ab[i]
        end
        coef[i] = c
    end
   
    return op_a, op_ab, mat, coef
end

```

but everytime i call this function `op_mat(x+y)`of course with `x=symbols("x") ; y=symbols("y")` i get this error:

```julia
ERROR: MethodError: no method matching getindex(::Sym, ::Symbol)
Closest candidates are:
  getindex(::Sym, ::Sym...) at /Users/midow/.julia/packages/SymPy/1Cwgd/src/utils.jl:18
  getindex(::Number) at number.jl:75
  getindex(::Number, ::Integer) at number.jl:77
  ...
Stacktrace:
 [1] op_mat(::Sym) at /Users/midow/.julia/packages/QuantumRelay/pjKWG/src/operateurs.jl:70
 [2] top-level scope at REPL[7]:1 

```

i don’t k,ow if a problem of syntax or not

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [October 17, 2019, 4:36am UTC](https://discourse.julialang.org/t/did-sympy-change-the-syntax/30007/2 "2019-10-17T04:36:39Z")

</div>

You need to use `op.as_poly` instead of `op[:as_poly]`. Same for `op.x[:gens]`, `op[:length]`, etc.
