Help a C++ coder see the light

Mark Charsley mark.charsley at
Thu Jan 30 19:11:00 CET 2003

I've been coding C++ for years now and Python for a few months. 
Incidentally, I'd say that Python's greatest strength is that it took me 
about two months to become as competent at Python as I was after two years 
of C++.

However, what's nice flexibility in a small Python project (we're using 
python to script a callback interface, and its very easy to support 
arbitrary functions taking arbitrary arguments) would give me the 
screaming heebie-jeebies in a larger project.

I'm used to the compiler/linker giving me a lot of reassurance that my 
code works. Python removes that reassurance and just leaves it to runtime 

The most annoying is typos along the lines of:

if myVar < 0:
    myVal = -myVar

which I believe PyChecker (and probably other tools) can catch.

The more nasty problem is changing a function to have, say, an extra 
argument. In C++ I'd just run the code through the compiler and it would 
tell me all the places where the code needs updating. In python I'd have 
to trust grep (and follow up all the cases where the function was assigned 
a new name, passed to a callback interface etc. and/or where the arguments 
are built somewhere else and just passed in via "apply").

As far as I can tell, the only way to have the same confidence in ones 
code as you'd get with C++ (albeit using code that might take you a lot 
longer to write), is to have unit tests that exercise absolute 100% code 
coverage. Which is dauntingly difficult to create even in a more static 
language like C++.

However there are large programs out there written in python, so it 
obviously can be done. So are folks here just preternaturally good 
programmers that don't need the safety net of a compiler/linker? Are there 
some handy python code-coverage tools of which I am unaware? Or do they 
just trust to lots of testing and fixing run-time errors as and when they 
occur (which, I grant you, also happens in the C++ world with errors 
beyond the powers of cl.exe to catch)?



More information about the Python-list mailing list