[SciPy-user] SciPy Data Analysis Workbench

Gael Varoquaux gael.varoquaux at normalesup.org
Sat Jan 20 14:38:40 CST 2007

On Sat, Jan 20, 2007 at 03:01:28PM -0500, Gabriel Gellner wrote:
> Does using traits change from a Duck typing solution to a static
> typing (type checking) solution?

Well yes and no. There is type checking going on, but it happens at
run-time. The compiler (here a byte-code compiler) is not aware of this
type-checking and cannot perform optimisations, or checking of the code,
so no language theorist will call this type-checking.

> I have to admit I am vague on these issues, but all the books I have
> learned python from go crazy about not doing type checking (they say
> over and over that python is strongly typed, but not statically typed
> . . . and you should use duck typing not type checking).

I have begun to see this as an extention from the object-oriented maxim
"program to interfaces, not implementations". I think what all this
really means is that if a number is not an integer, but behaves like an
integer, then just go ahead with it. What is import is not the type (the
impementation), but how the object behaves (the interface).

Of course the standard techniques used in program analysis and proofs
that rely on types are much harder to implement with duck-typing (I am
not even sure they can be), and if you add python's monkey patching
abilities, than all hopes of type-based proofs disappear.

> As from what I have read (as a previous fortran programmer) I find
> traits very, very intriguing (especially the easy generation of a gui).

Traits is a way of constraining the values the attributes of an object
can take by adding run-time checks.

TraitsUI uses the extra informations added by Traits to build dialogs
using simple rules. The example on the traits page is quite easy to
understand, I find: http://code.enthought.com/traits/



More information about the SciPy-user mailing list