> with contextlib.redirect_stdout(zen := io. In many ways, the design philosophy I used when creating Python is probably one of the main reasons for its ultimate success. In Python3.8+ you can also do: > import contextlib, io Zen of Python: Listing of Python design principles and philosophies that are. The Zen of Python: A guide to Pythons design principles. Pythons virtual machine executes the bytecode emitted by the bytecode compiler. That would look like this: > import contextlib, io Python is at the peak of the programming food chain right now. This code works on python2.7 - for python 3, use io.StringIO instead of cStringIO.StringIO, and also have a look at contextlib.redirect_stdout which was added in 3.4. Namespaces are one honking great idea - let's do more of those! If the implementation is easy to explain, it may be a good idea. If the implementation is hard to explain, it's a bad idea. There should be one- and preferably only one -obvious way to do it.Īlthough that way may not be obvious at first unless you're Dutch.Īlthough never is often better than *right* now. In the face of ambiguity, refuse the temptation to guess. This poster shows all 19 'guiding principles' that were written by software engineer Tim Peters in 1999. Special cases aren't special enough to break the rules. Zen of Python is a set of principles for writing computer programs that deeply influenced the design of the Python programming language. You can temporarily redirect stdout to a StringIO instance, import this, and then get its value.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |