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 _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com