Re: Are the property Function really useful?

Discussion in 'Python' started by Dieter Maurer, Aug 30, 2012.

  1. <> writes:

    > Are the property Function really useful?


    Someone invested time to implement/document/test it.
    Thus, there are people who have use cases for it...

    > Where can i use the property function?


    You can use it when you have parameterless methods
    which you want to access as if they were simple attributes:
    i.e. "obj.m" instead of "obj.m()".
    To phrase is slightly differently: the "property" function
    allows you to implement "computed" (rather than "stored") attributes.

    You may find this feature uninteresting: fine, do not use it...

    However, there are cases where it is helpful, e.g.:

    You have a base class "B" with an attribute "a".
    Now, you want to derive a class "D" from "B" where "a" is
    not fixed but must be computed from other attributes.


    The "Eiffel" programming language even stipulates that
    attributes and parameterless methods are essentially the same
    and application of the "property" function is implicit in "Eiffel"
    for parameterless methods: to hide implementation details.

    As you see, "property" can be highly valued ;-)
     
    Dieter Maurer, Aug 30, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hattuari
    Replies:
    11
    Views:
    838
    Julie J.
    Feb 26, 2004
  2. Franz Steinhaeusler

    Tabnanny really useful?

    Franz Steinhaeusler, Dec 20, 2004, in forum: Python
    Replies:
    16
    Views:
    500
    Stuart Bishop
    Dec 23, 2004
  3. Benny Ng
    Replies:
    3
    Views:
    582
    Benny Ng
    Dec 1, 2006
  4. Mark Lawrence
    Replies:
    0
    Views:
    189
    Mark Lawrence
    Aug 29, 2012
  5. Dave Angel
    Replies:
    0
    Views:
    181
    Dave Angel
    Aug 30, 2012
Loading...

Share This Page