On Saturday, August 14, 2010, cousteau <cousteaulecommand...@gmail.com> wrote:
> On 12 ago, 11:38, Jason Grout <jason-s...@creativetrax.com> wrote:
>>
>> Well, there is a general trend towards using functions instead of
>> attributes in Sage.  I think the main reason is for documentation (I
>> wish python had attribute docstrings that we could query!).
>>
>
> They wouldn't be attributes (that would involve having several copies
> of the matrix data in the object), they would rather be properties. A
> property is a method that looks like an attribute (it doesn't use
> parenthesis), but calls a function each time it's used. E

Thanks for the clarification.  I'm sure Jason meant properties, which
still *do* have exactly the issue he described, despite the existence
of a function call.

There is no "trend" though away from properties in Sage - we never
used them, since they suck from an introspection *and* consistency
perspective.

> xample:
>
> sage: class Foo:
> ....:     @property
> ....:     def bar(self):
> ....:         """This is a function that returns 'hello'."""
> ....:         return 'hello'
> ....:
> sage: a=Foo()
> sage: a.bar
> 'hello'
> sage: a.bar?
> Type:           property
> Base Class:     <type 'property'>
> String Form:    <property object at 0xb2822fc>
> Namespace:      Interactive
> Docstring:
>     This is a function that returns 'hello'.
> (...)
>
> --
> To post to this group, send an email to sage-devel@googlegroups.com
> To unsubscribe from this group, send an email to 
> sage-devel+unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>

-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to