It may also support slices, as in: In [20]: Part(x*y+w*z, slice(None, None, None), 1) Out[20]: y + z
In [21]: PartReplace(x*y + w*z, o, slice(None, None, None), 1) Out[21]: o⋅w + o⋅x Which would be roughly something equivalent to the intended usage of this wrong python expression: *expr.args[:].args[1] = o* On Sunday, 27 September 2015 23:39:46 UTC+2, Francesco Bonazzi wrote: > > > > On Sunday, 27 September 2015 00:34:20 UTC+2, Aaron Meurer wrote: >> >> What is PartReplace supposed to do? For me it just returns the >> replacement. >> >> > I updated the gist to make it act as a replacement: > > > In [14]: PartReplace(x*y+z, w, 1,1) > Out[14]: w⋅x + z > > > This should basically act to replace element at position > *.args[1].args[1]* with *w*. Of couse I avoided using the syntax > *expr.args[1].args[1] > = w* to comply with SymPy's immutability of objects. > > In [15]: (x*y+z).args[1].args[1] > Out[15]: y > > This gets element at (1,1), or the equivalent form in my gist: > > In [18]: Part((x*y+z), 1, 1) > Out[18]: y > > I think that *Basic* could be equipped with these two methods. > > > > -- 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 post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/a5ac29f7-240d-4da6-84c2-a5f015c450ce%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
