[SciPy-dev] Fwd: mlabwrap high-level user interface

Brian Hawthorne brian.lee.hawthorne@gmail....
Wed May 2 17:04:47 CDT 2007


---------- Forwarded message ----------
From: Brian Hawthorne <brian.lee.hawthorne@gmail.com>
Date: May 2, 2007 2:58 PM
Subject: Re: mlabwrap high-level user interface
To: Alexander Schmolck <a.schmolck@gmx.net>
Cc: scipy-dev@scipy.org, Matthew Brett <matthew.brett@gmail.com>, Taylor
Berg-Kirkpatrick <tberg@berkeley.edu>



On 4/30/07, Alexander Schmolck <a.schmolck@gmx.net> wrote:
>
> [moving this to scipy-dev]
>
> "Brian Hawthorne" <brian.lee.hawthorne@gmail.com> writes:
>
> > Ah, forgot one critical use case, the function call!
> >
> >>>> res = engine.svd(X, nout=1)
> >>>> res = engine["svd"](X, nout=1)
>
> As I mentioned in the other poist, I don't like that. There ought to be
> one
> way to do things, and the first type of call is clearly what we'd like
> function calls to typically look like.


Agreed, a single way to do things is preferable to multiple arbitrary
choices.  I was
thinking of rarer cases for the dictionary style lookup, with attribute
style being the
common use case.  For example:

  1)  Building layers on top (like an object browser), one might like to
say:

       >>> for name in engine.names: do_something_with(engine[name])

       But I guess in such a case, you could always just use the built-in
getattr function.

  2) Name conflicts.  In the rare case that some lunatic named a matlab
variable "__getattr__",
      you could retrieve its value with engine["__getattr__"], whereas
engine.__getattr__ would
      return a bound python method.

I suspect that ``engine["svd"]`` ought to be equivalent to ``engine.svd()``.
>
> The reason why I'd at least strongly consider this funny looking behavior
> that
> is that nullary-function call vs. variable lookup is below the interface
> level
> in matlab (i.e. syntactically undistinguishable and hence something that
> one
> is often at liberty to change for a variable that isn't intended for
> mutation;
> a bit like property access can be transparently replaced by a function
> call in
> python (using e.g __getattr__) but not in lesser languages like java or
> C++).


Hmm, that does throw a wrench in the works

-brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-dev/attachments/20070502/b6c5b42a/attachment.html 


More information about the Scipy-dev mailing list