|
|
Subscribe / Log in / New account

From late-bound arguments to deferred computation, part 2

From late-bound arguments to deferred computation, part 2

Posted Aug 30, 2022 8:39 UTC (Tue) by jem (subscriber, #24231)
In reply to: From late-bound arguments to deferred computation, part 2 by milesrout
Parent article: From late-bound arguments to deferred computation, part 2

Python is huge as a language for teaching programming. This point in particular is one of the most unintuitive aspects of one of the most intuitive programming languages.

The root of this problem is the existence of argument defaults in the first place. Without them Python would be an even more intuitive programming language for beginners. In the Zen of Python the second principle is "Explicit is better than implicit.". Also: "Simple is better than complex.", "Readability counts.", and "There should be one – and preferably only one – obvious way to do it.".


to post comments

From late-bound arguments to deferred computation, part 2

Posted Aug 30, 2022 9:36 UTC (Tue) by milesrout (subscriber, #126894) [Link]

Default arguments do not make things less explicit.

Frankly I find that the Zen of Python is cited more by non-Python programmers as an attempted "gotcha!" based on Python violating their interpretations of it. I rarely see it referred to by Python programmers these days. The whole point of it is meant to be that most of the points are followed by a counterpoint that says 'but don't take it too far'.

'Simple is better than complex' is immediately followed by 'complex is better than complicated' and personally I think it would be overcomplicated to need to write range(0, n) everywhere instead of range(n), even if it's a little "complex" that range has a default argument that comes *before* its normal arguments. No Python beginner that I've ever taught has found that particular point difficult or confusing.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds