Hi Nicolas,

On 2016-04-29, Nicolas M. Thiery <nicolas.thi...@u-psud.fr> wrote:
> There is one use case for properties in the public API though which I
> would like to bring up, namely "glorified methods". Let me explain:

So, briefly, these are properties (or lazy attributes) that behave,
syntactically, like methods, right?

Do we consider it as "frustrating experience" when one has to type
M.f()(x) rather than M.f(x), when M.f resp. M.f() is, say, a morphism?

I find it only mildly frustrating.

And how frustrating is it when
  M.f?
shows the documentation of the morphism, rather than the documentation
of the underlying construction that outputs the morphism?

Here, I would prefer to see *not* the documentation of the morphism
(which typically is general nonsense on *all* morphisms). Instead, I
want to see the documentation of the construction of that specific
morphism.

What do different approaches give?

  sage: class Foo(object):
  ....:     @property
  ....:     def bar(self):
  ....:         "bla"
  ....:         return 1
  ....:     
  sage: F = Foo()
  sage: F.bar?
gives the desired result (docstring of Foo.bar), whereas
  sage: class Foo(object):
  ....:     @lazy_attribute
  ....:     def bar(self):
  ....:         "bla"
  ....:         return 1
  ....:     
  sage: F = Foo()
  sage: F.bar?
gives general nonsense about integers.

So, from the point of view of documentation, I find
@property fine for API, but @lazy_attribute not. But the problem
is that the computation in @property is repeated when repeatedly
accessing the property. Under that point of view: Why should I
use properties at all, when all what they do is saving me
from typing "()"? In that regard, @lazy_attribute is better.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to