Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue May 12 21:14:56 EDT 2015
On Wed, 13 May 2015 02:05 am, Chris Angelico wrote:
> So if you're writing a library function, it probably shouldn't use
> print()... but your application is most welcome to. You usually know
> which one you're writing at any given time.
You might be, but beginners are not.
I'm not sure I accept Rustom's fix for the problem (I think that his cure is
worse than the disease), but it is *hard* to get some beginners to use
return instead of print:
def add_twice(x, y):
"""Add twice y to x."""
print x + 2*y
sort of thing.
Personally, I think that banning print is only useful if you wish to
encourage cargo-cult programming:
"Don't use print!"
"Why not?"
"My CS lecture said not to use it! I dunno, maybe it has a virus or
something."
I'd rather give them exercises designed to show (rather than tell) the
differences between printing a result and returning a result, and how they
effect re-usability of software components and function chaining. Using a
procedural language is *perfect* for that, since you can highlight the
differences:
function foo(n:int): int;
begin
foo := n+1;
end;
procedure foo(n:int);
begin
writeln(n+1);
end;
--
Steven
More information about the Python-list
mailing list