"no variable or argument declarations are necessary."

D H no at spam
Sun Oct 2 23:06:25 CEST 2005


James A. Donald wrote:
> I am contemplating getting into Python, which is used by engineers I
> admire - google and Bram Cohen, but was horrified to read
> 
> "no variable or argument declarations are necessary."
> 
> Surely that means that if I misspell a variable name, my program will
> mysteriously fail to work with no error message.
> 
> If you don't declare variables, you can inadvertently re-use an
> variable used in an enclosing context when you don't intend to, or
> inadvertently reference a new variable (a typo) when you intended to
> reference an existing variable.
> 
> What can one do to swiftly detect this type of bug?

It's a fundamental part of python, as well as many other scripting 
languages.
If you're not comfortable with it, you might try a language that forces 
you to declare every variable first like java or C++.
Otherwise, in python, I'd recommend using variable names that you can 
easily spell.  Also do plenty of testing of your code.  It's never been 
an issue for me, although it would be nicer if python were 
case-insensitive, but that is never going to happen.



More information about the Python-list mailing list