On Fri, Feb 5, 2010 at 10:40 AM, Hansen, Mike mike.han...@atmel.com wrote:
Perl has use strict; to force variable declaration.
My insane Perl loving co-workers think it's evil that Python doesn't have
variable declaration. =)
What are some of the reasons/arguments on why Python doesn't need variable
declaration? I've gotten around it in Python by using Pyflakes to check my
code and catch those silly mis-spelling of a variable.
I've never had any serious problems (though I've never worked on huge
projects with Python), but here are some of the reasons that pop into my
mind:
1) We're big boys and girls - we're responsible enough to pay attention to
our variables
2) I have no clue, but it may make it easier on the garbage collection -
once a value/object no longer has a reference it can probably be cleared up.
But those c variables you declared way back in the beginning of your
program? Still there (though an anti-argument would be that you're not using
scope properly in this case)
3) If you're writing a small program you should be able to see everything,
but if you're using a big enough program you should be using an IDE that
keeps track of that sort of thing.
I don't know how valid those reasons would be considered... but I, for one,
like the freedom of not having to type:
int a = 0;
or
int a;
MyClass(){
a = 0;
}
or any other waste of keystrokes. If I want a new variable, I'll make it
responsibly - whether I need it here or there...
but that's my two cents
-Wayne
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor