![]() Python would prefer that you write out your program in a way that is easy to read. ![]() Various programming languages are great at “code golf”, providing incredibly terse ways to get a lot of functionality. If they are useful, they belong at the surface. Think of the Law of Demeter: do not make people reach into the innards of modules or objects to find things that are useful. When something is not straightforward it should be because what you are trying to do is not straightforward not because the tool makes it harder. Simple to implement, or simple to use? Yes. Other operations implicitly set $_, so knowing the behaviour of a Perl script can mean knowing the behaviour of Perl, not understanding the instructions in the script. In fact it is more likely to be a dig at a design choice in Perl, where unary functions (one argument) also have a nullary (zero-argument) form: chomp $foo strips trailing whitespace from $foo, while chomp acts on the $_ variable. This can be read as a preference for configuration over convention: do things I say, and only things I say. We are considering not just the practicality of programming with this tool, but the experience of using the tool, too. Well, this is clearly subjective, but still important: we are taking subjective principles into account. There are only 19 lines, we may as well go through each one! Beautiful is better than ugly. This sort of information is priceless: knowing how your programming language was designed will help you understand how to read code written in it, and write your own code. This document is published as PEP 20 - The Zen of Python. Type import this into the Python interpreter and you will get a short collection of aphorisms that each summarise a design principle of the Python language (or really of Guido van Rossum). This month, we are going to read an Easter egg in a programming language. A good programmer’s library (I will let you decide whether that is a good library owned by a programmer, or a library belonging to a good programmer) includes essays, scholarly articles, videos, magazines, blog posts, podcast episodes, and more. Not everything that is worth reading is a book.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |