PEP 8 and properties

John Roth johnroth at
Fri Jan 24 21:52:57 CET 2003

"Ian Bicking" <ianb at> wrote in message
news:mailman.1043357026.17812.python-list at
> On Mon, 2003-01-20 at 20:41, John Roth wrote:
> > I think so. As far as I'm concerned, the difference
> > is that a variable is something, while a method does
> > something. I know this isn't as clear a distinction as
> > I'd like, but then, most things have real fuzzy edges.
> This was my initial thought too.  Or I'd say, anything that has side
> effects should be a method.  So I've been using properties for
> calculated or dependent values, so I might have a color object that
> red, green, and blue attributes.  It also has hue, saturation, and
> attributes.  Red, green and blue are orthogonal to each other (though
> course limited to be numbers, etc).  But they are not orthogonal to
> saturation and value.  Obviously one of these is calculated, though it
> could actually be either one.  Or heck, hue, value and green could be
> the master attributes (if I wanted to work out the math :).
> But okay, I'm fine with that.  I'm also okay with side effects that
> for caching purposes.  If you have calculated values it's only normal
> add caching at some point in the process, and you don't want to change
> the interface in order to do that.  I'm also okay with side effects
> might even involve writing a cached value to disk.
> But then there's other calculated values I'm not so sure about.  In
> example maybe something like isBlack.  It's kind of calculated, but
> constant for the color (assuming the color is immutable).  It would
> certainly never take an argument.  But I'm a little less comfortable
> with this... somehow it seems wrong for a test to be an attribute, and
> not a function.  But I know a lot of languages with properties use
> style often.

Intuitively, I'd agree with you. isBlack() certainly looks like a
function to me, not a variable. In fact, it intuitively suggests that
is an underlying variable named 'color.'

In general, "is" questions are, to me, functions.

John Roth

> I feel like there's other cases I haven't come up with, where the
> I've decided on so far don't apply, or they do but I disagree with
> for that case.  There's no Python convention to go on in these cases,
> either.
> --
> Ian Bicking           Colorstudy Web Development
> ianb at
> PGP: gpg --keyserver --recv-keys 0x9B9E28B7
> 4869 N Talman Ave, Chicago, IL 60625 / (773) 275-7241

More information about the Python-list mailing list