Page 93 -
P. 93
sharing your code
Python tries its best to run your code
Unlike compiled languages (such as C, Java, C#, and others), Python doesn’t
completely check the validity of your code until it runs. This allows Python to do
some rather cool things that just aren’t possible in those other languages, such
as dynamically defining functions at runtime. This, of course, can be very
flexible and powerful.
The cost to you, however, is that you need to be very careful when writing
your code, because something that typically would be caught and flagged as
an “error” by a traditional, statically typed, compiled language often goes
unnoticed in Python.
...OK, C++ syntax fine...continuing to
parse...whoops! You’re trying to use a
function before it’s declared?!? That’s NOT
allowed around here... I’m outta here.
Please wait.
Compiling
your C++
code…
Ah ha! The old “calling
a function before you’ve defined
it yet” trick, eh? I’ll just make a note
in case you define it later at runtime.
You are planning to do that, right?
Please don’t disappoint me, or I’ll give
you an error...
Running your
Python code
right now…
Take another look at the error on the opposite
page. Why do you think Python is giving you this
particular error? What do you think is wrong?
you are here 4 57