Writing Idiomatic Python 2.7.3
Jeff Knupp, 2013
The "Writing Idiomatic Python" book is finally here! Chock full of code samples, you'll learn the "Pythonic" way to accomplish common tasks. Each idiom comes with a detailed description, example code showing the "wrong" way to do it, and code for the idiomatic, "Pythonic" alternative. *This version of the book is for Python 2.7.3+. There is also a Python 3.3+ version available.* "Writing Idiomatic Python" contains the most common and important Python idioms in a format that maximizes identification and understanding. Each idiom is presented as a recommendation to write some commonly used piece of code. It is followed by an explanation of why the idiom is important. It also contains two code samples: the "Harmful" way to write it and the "Idiomatic" way. * The "Harmful" way helps you identify the idiom in your own code. * The "Idiomatic" way shows you how to easily translate that code into idiomatic Python. This book is perfect for you: * If you're coming to Python from another programming language * If you're learning Python as a first programming language * If you're looking to increase the readability, maintainability, and correctness of your Python code What is "Idiomatic" Python? Every programming language has its own idioms. Programming language idioms are nothing more than the generally accepted way of writing a certain piece of code. Consistently writing idiomatic code has a number of important benefits: * Others can read and understand your code easily * Others can maintain and enhance your code with minimal effort * Your code will contain fewer bugs * Your code will teach others to write correct code without any effort on your part
What people are saying - Write a review
We haven't found any reviews in the usual places.
Other editions - View all
__getitem__ __main__ __name__ absolute imports as_html attributes automated testing bar_has_hopped baz_coefficient CharField checking client code code samples code written context manager create def __init__(self def make_api_call(foo default argument default value defined dict display_uptime(uptime_in_seconds docstring element in elements elif error example False filename_to_archive flask foo import foo_polarity format string function functional programming giant robots attack Gizmo Harmful def hash_value idiom idiomatic code Idiomatic def immutable objects import package.other_module import statements import sys iterate keyword arguments languages list comprehension loop median mutable object my_list name mangling operator os.path output package parameters PEP8 print_list(the_other_list programming PyPI Python code quux_capacitor raise an exception range(1 refactoring result return value returns True right_operand script SECOND_NUMBER SECONDS_IN_A_DAY self.id sequence should_raise_shields some_list standard library switch...case sys.exit ternary operator test code there's tool truthiness tuple unit tests variable writing code