declaration of variables?

Brian Quinlan brian at sweetapp.com
Sun Feb 16 18:58:38 EST 2003


> This isn't a valid counterargument, at least for function locals.  The
> Python compiler does determine all the local variables used in a
> function at compile time.  Declarations merely force the human
> programmer to do something the compiler could do automatically, all
> for the sake of catching an occasional typo.

But you could only do this for locals. Global, instance and class
variables would be missed. So you'd end up with an inconsistency in the
language that probably wouldn't catch most bugs anyway. I don't think
that my argument is invalid when it does not apply to 1 of 4 cases. 

> > As an example, imagine that I write a RPC
> > client that must be able to receive proxies to object instances. How
> > would I know what variables that object has at compile-time?
> 
> Those are attributes, not variables.  I don't believe the OP was
> suggesting that we be able to declare attributes; and if he were, we
> could tell him that Python optionally allows that with __slots__.

I think that the attribute/variable distinction is weaker than you
think. 
 
Cheers,
Brian






More information about the Python-list mailing list