[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

the core values of the Python "platform"

Steven D'Aprano wrote:
> On Wed, 13 Sep 2017 09:08:41 -0400, Darin Gordon wrote:
>> Bryan Cantrill gave an interesting talk recently at a Node conference
>> about "platform values" [1].
> For those of us who don't have the time or inclination to watch a video,
> or who are unable to, could you summarise these platform values?
>> The talk lead me to think about what the
>> core values of the Python "platform" are and I thought it would be good
>> to ask this question of the community. What would you consider the top
>> (<= 5) core values?
> In no particular order:
> - The Zen of Python ("import this" at the interactive interpreter).
> - "We're all adults here." We tend to be more relaxed about theoretical
> errors, and push some of the responsibility for defensive programming
> onto the caller, not just the callee. If the caller breaks my function's
> contract by providing bad arguments, or messes with my class' internals,
> they deserve whatever bad things happen.
> - "We're all adults here." The flip side of that is that if I choose to
> mess with your private methods or functions, you shouldn't take
> extraordinary steps to try to prevent me. I'm an adult, and if I've got
> good reason to call your private method (say, I'm debugging, or I'm
> simply exploring the capabilities at the interactive interpreter) then I
> should be allowed. If I want to shoot myself in the foot, it isn't your
> responsibility to prevent me.
> - All else being equal, it is better to ask forgiveness than permission.
> In general, we prefer try...except and catching exceptions than to look
> before you leap. It is often faster, but more importantly, it avoids
> "Time Of Check To Time Of Use" bugs.
> - Python is in one sense a pure Object Oriented language (all values,
> even integers, are objects)

Even classes are objects.

>   but in another sense Python is a multiparadigm
> language. Not everything needs to be a class. Top-level functions are
> often better. We can, and do, write code using four of the big five
> programming paradigms: procedural, OOP, functional, imperative. And mix
> and match them within a single code base.
> (Only deductive/logic programming has little support in Python.)
> And if I may be allowed a sixth:
> - Not every two line function needs to be a built-in.