[Python-Dev] properties on modules?

Mark Hammond mhammond@skippinet.com.au
Tue, 14 Jan 2003 11:49:35 +1100


[Brian Quinlan]

> Presumably, he would prefer this syntax:
>
> start = time.now
>
> to:
>
> start = time.now()
>
> The .NET framework implements "now" as a property rather than
> a function
> and I find it distasteful for some reason.

Interestingly, <plug> a new, wonderful book called "Programming in the .NET
Environment", co-authored by me
(http://www.aw.com/productpage?ISBN=0201770180 or
http://www.amazon.com/exec/obidos/tg/detail/-/0201770180/qid=1042505176) has
some information on this </plug> ;)

One of the other authors is the Program Manager for the .NET framework class
library.  He has written the MS design guidelines for the .NET framework, so
we asked him to paraphrase them in our book.  One part of this (page 241)
deals specifically with properties and methods.

One of the guidelines states that a property should *not* be used "if
calling the member twice in succession produces different results".

So clearly, this violates the .NET design guidelines - unless, of course,
you call it twice *very quickly* <wink>.

Mark.