newbie questions

Jeff Norden jeff at norden.math.tntech.edu
Fri Jun 11 11:12:03 EDT 1999


I've been tinkering with python for a few days.  I have to admit that my
first impression was that this language would turn me into a newt, but I got
better :-)

A few questions:

1) Is there no equivalent to perl's  "use strict" in which all variables
have to be declared?  How about perl's "-w" flag, which at least gives a
warning when a variable is only used once.  These features are nice for
catching common mistakes, i.e., if you try to increment spam with

   span = spam + 1

python will just create a new span variable, and no error message.
Or, consider the even more insidious error:   vikingl = viking1 + spam

2) Is the above the correct way to increment a variable?  I can't find an
equivalent for "++" or "+="

3) These are rather minor, but is there no way to "forward declare" function
definitions?  I'd rather put them at the end of the file instead of the
beginning.  Python does parse the whole file before it starts execution,
doesn't it?  Also, is there a way to just check for syntax errors without
execution, like perl's "-c" switch?

Thanks in advance,
  -Jeff Norden, jeff at math.tntech.edu
   Dept of Math, Tenn Tech Univ, Cookeville TN




More information about the Python-list mailing list