Explicit variable declaration

Filip Gruszczyński gruszczy at gmail.com
Fri Apr 25 12:23:43 EDT 2008


>  In Python the standard patten for "declaring" variables is just to assign to
>  them as they are needed.  If you want the effect of a declaration as you
>  would do in C, you can just define the variable and initialize it to 0 or
>  None.  (Or {} for a new dictionary, or [] for a new list.)

Yep, I get it and I absolutely love this about Python. What I don't
actually love is situation, where I misspell and instead of setting
one variable, other is created. This is why I would like to declare
variables first and say, that these are the only ones, that can be set
in certain function (the same with fields in a class).

I am finishing a small tool, that allows to create such declarations
in similar manner to Smalltalk declarations. I hope I can post a link
to it soon.

-- 
Filip Gruszczyński


More information about the Python-list mailing list