Evaluating python - a question

Just van Rossum just at letterror.com
Fri May 18 05:39:56 EDT 2001


[me]
> > Equal chance of mistyping, yes, but the point was that a typo in an
> > accessor method triggers an exception, whereas simply setting an
> > attribute does not:
> >
> > class Foo:
> >     def __init__(self):
> >         self.foo = 1
> >     def setFoo(self, value):
> >         self.foo = value
> >
> > f = Foo()
> > f.fooo = 2    # no exception
> > f.setFooo(2)  # boom

Alex Martelli wrote:
> A terminology issue: this seems to be about MUTATOR methods rather
> than ACCESSOR ones.  ACCESSING a non-existent attribute raises an
> exception just as much as calling a non-existent accessor method.

Thanks for setting this straight: I thought the term accessor was used
for both setting and getting. (Still, I think that setting an attribute
is also a form of "access"...)

Just



More information about the Python-list mailing list