|
From: Christophe B. <pro...@gm...> - 2013-03-15 15:01:10
|
Hello, I really appreciate the work done by matplotlib but I really think that the interface must evolve. Here is a small example. * object.set_something(...)* * object.get_something()* It could be easier to use a jQuery like style as in the following lines. * object(...)* * object()* This will considerably simplify things. Here is a more realistic example. * fig = pylab.figure()* * ax = fig.add_subplot(1,1,1)* * * * ax.set_xlabel(*"xLabel"*)* * ax.set_ylabel(*"yLabel"*)* The a jQuery like style would be as in the following lines. * fig = pylab.figure()* * ax = fig.add_subplot(1,1,1)* * * * ax(xlabel = *"xLabel"*, ylabel = *"yLabel"*)* * * I don't know enough matplotlib to propose other examples but I really think that there is a lot of things that could make matplotlib much more Pythonicly easy to use. Christophe BAL |
|
From: Paul H. <pmh...@gm...> - 2013-03-15 15:19:20
|
On Fri, Mar 15, 2013 at 8:01 AM, Christophe BAL <pro...@gm...> wrote: > Hello, > I really appreciate the work done by matplotlib but I really think that > the interface must evolve. Here is a small example. > > * object.set_something(...)* > * object.get_something()* > > It could be easier to use a jQuery like style as in the following lines. > > * object(...)* > * object()* > > This will considerably simplify things. > > > Here is a more realistic example. > > * fig = pylab.figure()* > * ax = fig.add_subplot(1,1,1)* > * > * > * ax.set_xlabel(*"xLabel"*)* > * ax.set_ylabel(*"yLabel"*)* > > The a jQuery like style would be as in the following lines. > > * fig = pylab.figure()* > * ax = fig.add_subplot(1,1,1)* > * > * > * ax(xlabel = *"xLabel"*, ylabel = *"yLabel"*)* > * > * > I don't know enough matplotlib to propose other examples > but I really think that there is a lot of things that could make > matplotlib much more Pythonicly easy to use. > > Interesting thoughts, Christophe. There is currently a MEP to do something similar: https://github.com/matplotlib/matplotlib/wiki/MEP13 |
|
From: Brendan B. <bre...@br...> - 2013-03-15 18:40:02
|
On 2013-03-15 08:19, Paul Hobson wrote:> On Fri, Mar 15, 2013 at 8:01 AM, Christophe BAL <pro...@gm...> wrote: > >> Hello, >> I really appreciate the work done by matplotlib but I really think that >> the interface must evolve. Here is a small example. >> >> * object.set_something(...)* >> * object.get_something()* >> >> It could be easier to use a jQuery like style as in the following lines. >> >> * object(...)* >> * object()* > Interesting thoughts, Christophe. There is currently a MEP to do something > similar: > https://github.com/matplotlib/matplotlib/wiki/MEP13 I think the current situation is better than this jQuery style, and the MEP is better than the current situation. Using lots of verbose getters and setters is unpythonic, but calling objects directly in that catch-all way is even more unpythonic. There are lots of things you might want to do to an MPL object, and we shouldn't elevate attribute get/set as the "main one" that should be accessed by the call syntax. That MEP would be great, though! -- Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown |
|
From: todd r. <tod...@gm...> - 2013-03-15 15:39:27
|
On Mar 15, 2013 4:01 PM, "Christophe BAL" <pro...@gm...> wrote:
>
> Hello,
> I really appreciate the work done by matplotlib but I really think that
> the interface must evolve. Here is a small example.
>
> object.set_something(...)
> object.get_something()
>
> It could be easier to use a jQuery like style as in the following lines.
>
> object(...)
> object()
>
> This will considerably simplify things.
>
>
> Here is a more realistic example.
>
> fig = pylab.figure()
> ax = fig.add_subplot(1,1,1)
>
> ax.set_xlabel("xLabel")
> ax.set_ylabel("yLabel")
>
> The a jQuery like style would be as in the following lines.
>
> fig = pylab.figure()
> ax = fig.add_subplot(1,1,1)
>
> ax(xlabel = "xLabel", ylabel = "yLabel")
>
> I don't know enough matplotlib to propose other examples
> but I really think that there is a lot of things that could make
> matplotlib much more Pythonicly easy to use.
>
> Christophe BAL
>
I don't personally like this approach. Python has very clear separation
between the initialization of methods, which acts like a function that
returns an instance, and the modification of existing instances, which uses
attributes. This syntax muddies the distinction, having something that
should behave like an instance instead behaving as a function.
Is there any precedence for using this sort of syntax in python? I have
not seen it anywhere else. You mention jQuery, but that is JavaScript not
python. As far as I have seen
|
|
From: Jerzy K. <jer...@un...> - 2013-03-15 16:21:25
|
Christophe BAL: > I really appreciate the work done by matplotlib but I really think that > the interface must evolve. Here is a small example. > > * object.set_something(...)* > *object.get_something()* > > It could be easier to use a jQuery like style as in the following lines. > > *object(...)* > *object()* > > This will considerably simplify things. > > > Here is a more realistic example. > > *fig = pylab.figure()* > *ax = fig.add_subplot(1,1,1)* > * > * > *ax.set_xlabel(*"xLabel"*)* > *ax.set_ylabel(*"yLabel"*)* > > The a jQuery like style would be as in the following lines. > > *fig = pylab.figure()* > *ax = fig.add_subplot(1,1,1)* > * > * > * ax(xlabel = *"xLabel"*, ylabel = *"yLabel"*)* > * > * > I don't know enough matplotlib to propose other examples > but I really think that *there is a lot **of things that could make * > *matplotlib much more Pythonicly easy to use.* I am afraid I disagree a little bit. The call: object(...) [if object is an instance, not a class, otherwise ths would be a constructor] - - means object.call(...). Now, in principle one can throw inside a generic "call" plenty of attribute changes, but just imagine the parsing of all the possible argument combination. And, BTW, what would it mean: xxx= ax() ? In general case this is not practical. The methods in Python called.through.the.dot.notation are there to stay, I think. Jerzy Karczmarczuk Caen, France. |
|
From: Joe K. <jof...@gm...> - 2013-03-15 18:15:47
|
On Mar 15, 2013 10:01 AM, "Christophe BAL" <pro...@gm...> wrote:
>
> Hello,
> I really appreciate the work done by matplotlib but I really think that
> the interface must evolve. Here is a small example.
>
> object.set_something(...)
> object.get_something()
>
> It could be easier to use a jQuery like style as in the following lines.
>
> object(...)
> object()
>
> This will considerably simplify things.
>
>
> Here is a more realistic example.
>
> fig = pylab.figure()
> ax = fig.add_subplot(1,1,1)
>
> ax.set_xlabel("xLabel")
> ax.set_ylabel("yLabel")
>
> The a jQuery like style would be as in the following lines.
>
> fig = pylab.figure()
> ax = fig.add_subplot(1,1,1)
>
> ax(xlabel = "xLabel", ylabel = "yLabel")
>
Just fyi: you can always do
ax.set(xlabel="something", ylabel="something")
> I don't know enough matplotlib to propose other examples
> but I really think that there is a lot of things that could make
> matplotlib much more Pythonicly easy to use.
>
> Christophe BAL
>
>
------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
|