[Python-3000] Builtin iterator type

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Nov 19 02:15:59 CET 2006


George Sakkis wrote:

> The end user may not have to explicitly test for it, but it happens
> anyway behind the scenes; x.foo is functionally equivalent to
> if hasattr(x,'foo'): return getattr(x,'foo')
> else: raise AttributeError()

Well, yes, but the point is that since this is being
done automatically anyway, doing it yourself as
well is redundant.

> the textual check must
> happen at some point, and that this is inherently unsafer than a
> semantic check.

But testing for a base class is a rather crude form
of semantic check, because it bundles a lot of semantics
together that you often don't need bundled.

The only completely accurate semantic check is to run
the program and see if it produces the right result.
In other words, don't LBYL, but Just Do It, and use
unit tests.

--
Greg


More information about the Python-3000 mailing list