PEP 8 and properties
johnroth at ameritech.net
Tue Jan 21 03:41:37 CET 2003
"Jonathan P." <jbperez808 at yahoo.com> wrote in message
news:f57664b9.0301201645.1f10b82b at posting.google.com...
> "John Roth" <johnroth at ameritech.net> wrote in message
news:<v2mlb2s499teb2 at news.supernews.com>...
> > I think there's some confusion here. The dictum that
> > you don't expose variables comes from the "information
> > hiding" school of thought. A variable is part of the
> > internal implementation of the class, and you should
> > be able to change it freely. A function, on the other
> > hand, is part of an API, and doesn't constrain changes
> > to the implementation nearly as much.
> > Now, if the language includes properties, then the
> > assessment changes, because there is no external
> > difference between variables and properties. You
> > can publish a variable, and then if you want to change
> > the implementation so that the variable doesn't (even
> > conceptually) exist any more, you can make it
> > a property, which lets you slide the accessor functions
> > in under the hood.
> In other words, properties let us have our cake and eat
> it too. But they are flexible enough that you're going
> to have to enforce some strict conventions on their usage
> to avoid possible confusion. I'm starting to see how
> they can be Pythonic.
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.
More information about the Python-list