[Tutor] replacement for constants from other languages in Python?

Alan Gauld alan.gauld at freenet.co.uk
Thu Jan 6 23:25:51 CET 2005


> Compared to Java and C++, Python has very meager facilities 
> for controlling how code is used. There is no const, and only 
> the slightest nod to access control .... my 
> suggestion is, just relax and try the Python way!

I'll second that. I came to Python after years of C++ 
(and Pascal - even more strict!) and initially thought 
that Python's approach, while great for a scripting language, 
would lead to problems on bigger projects. Well, I haven't 
written anything truly huge yet but I haven't hit any more 
problems than I did in C/C++ so far - and C/C++ introduce 
their own problems with overly strict typing, especially 
in OOP work.

My experience of Smalltalk at university (and in Lisp too)
should have made me less concerned but years of indoctrination 
by the software engineering establishment had led me to 
believe in the idea of the language controlling the 
programmer rather than the other way around...

Although I haven't used it on big projects either, I suspect 
that Objective C as used in Apple's Cocoa framework may offer 
a good mix of freedom and strictness for large industry 
strength projects. The more I use Objective C the more I 
like its divisio of concerns betweentraditional C style 
coding and the OO features where dynamic dispatch is a 
huge win over C++/Java's strict typing.

Similarly features such as __FILE__ and __LINE__ are 
often used in C because the debugger and error reporting 
support is so poor, in a duynamic, interpreted language 
with full exception handling the need is restricted to 
log files and audit trails etc. So while I miss __LINE__ 
especially, I don;t need it nearly as much as I did in C.

And finally, because Python operates at a much higher 
level you only write a fraction of the code that you 
do in C, so the need for these navigation aids is much 
less.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


More information about the Tutor mailing list