Why not allow empty code blocks?

Chris Angelico rosuav at gmail.com
Sat Jul 30 12:37:42 EDT 2016


On Sun, Jul 31, 2016 at 2:15 AM, Rustom Mody <rustompmody at gmail.com> wrote:
> Diff between
> print "x"
> and
> print("x")
> is one char — the closing ‘)’
>
> To make a dispute about that — I’ll leave to BartC!
>
> The more general baby that is significant is that beginners should have
> it easy to distinguish procedure and function and python does not naturally aid that.  print was something procedure-ish in python2 but the general notion being
> absent is a much more significant problem (for beginners) than print.

But Py2's print is not just a procedure. It's magical syntax. You
can't create your own procedures.

Why SHOULD they be special? Ultimately, a procedure is simply a
function that has no useful return value; and there are myriad times
when I've called a function or method for its side effects and ignored
the return value. So do I need to be able to "call a function as if it
were a procedure", or is there a stark difference between the two
types of callable?

Where, in any useful production code, is the difference between
functions and procedures actually helpful? Or where, in student code,
would it be useful to distinguish? I've been teaching Python to
students with a variety of backgrounds, and nobody has yet been
bothered by this. Not a single one.

ChrisA



More information about the Python-list mailing list