On Sunday, January 19, 2014 10:29:58 AM UTC+5:30, Chris Angelico wrote: > On Sun, Jan 19, 2014 at 3:43 PM, Rustom Mody wrote: > > Because these two pieces of code > >>>> def foo(x): print x+1 > >>>> def bar(x): return x+1 > > look identical (to a beginner at least) > >>>> foo(3) > > 4 > >>>> bar(3) > > 4
> As do these pieces of code: > >>> def quux1(x): return str(x+1) > >>> def quux2(x): return hex(x+1)[2:] They do? >>> quux1(2.3) '3.3' >>> quux2(2.3) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 1, in quux2 TypeError: hex() argument can't be converted to hex If you want to give an irrelevant example at least give a correct one :D the difference between str and hex is an arcane difference (Ive never used hex) the difference between functions and procedures is absolutely basic. And python is worse than not just academic languages like haskell in this respect but even worse than C/Pascal etc. In Pascal, the difference between procedure and function is fundamental to the lang and is key to Pascal being good for academic purposes. In C, the difference is not so well marked but at least trivial code-examples found in books/the net wont run straight-off without some main-printf-etc boiler-plate. In python lots of easy to check examples run straight off -- convenient for programmers of course but a headache for teachers who are trying to set habits of minimal hygiene > But we don't decry hex or str because of it. Every function has its > use and purpose. If someone uses the wrong tool for the job, s/he will > have to figure that out at some point - it doesn't mean the tool is > wrong. > If you're not using the REPL, print is critical. Don't assume everyone > uses interactive mode. "Everyone uses interactive mode" is of course an unreasonable assumption "Everyone needs to learn (something or other at some time or other)" is not And print (especially in python) screws up the learning-curve tl;dr You are wearing 'professional programmer' hat I am wearing 'teacher' hat Not sure what hat Roy or Steven are wearing -- https://mail.python.org/mailman/listinfo/python-list