Matimus wrote: > On May 16, 9:57 am, HMS Surprise <[EMAIL PROTECTED]> wrote: >> I looked in the language but did not find a switch for requiring >> variables to be declared before use. >> >> Is such an option available? >> >> Thanks, >> >> jvh > > You do have to declare a variable before use. You do so by assigning > it a value. You can't use a variable before it has been assigned. In > some ways this is less ambiguous than even C where you can declare a > variable without assigning a value. Also note that this caries the > type information, since the variable is of whatever type was assigned > to it. The only thing it doesn't do is give a unique flag that says > "hey this is where I'm declared", although I suppose you could do that > with a comment. > Strictly, the variable has no type at all (and strictly your "variables" are actually names bound to values in a namespace, and it's the values that are typed).
We shouldn't ignore the fact that declarations unambiguously say "the programmer intends to use such-and-such a name for a value of a specific type". Contrast this with a Python program where one path makes an assignment (binding) to a name while another path doesn't, resulting in a later NameError. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden ------------------ Asciimercial --------------------- Get on the web: Blog, lens and tag your way to fame!! holdenweb.blogspot.com squidoo.com/pythonology tagged items: del.icio.us/steve.holden/python All these services currently offer free registration! -------------- Thank You for Reading ---------------- -- http://mail.python.org/mailman/listinfo/python-list