PyCon Pune 2017

A conference on the Python programming language

PyCon, the gathering for the community using and developing the open-source Python programming language. This is the first year of the PyCon Pune where the community will meet for two days of talks and working on upstream projects in two days of dev sprint. CFP ends on 30th November AoE.

Hosted by

PyCon Pune 2017 more

Anand Chitipothu

@anandology

Writing Beautiful Code

Submitted Nov 30, 2016

Writing code is hard. Writing beautiful code is even more so.

How to write code that is pleasant to read, easy to understand and joy to maintain?

Simple things like using right variable names, avoiding to much nesting, using white space and comments etc. makes a lot difference to readability of the code. Even though these things look very simple, it is very hard to put them in practice.

In this talk, I’ll try summarise the age old wisdom of writing beautiful code using python examples.

Outline

Choose meaningful variable names
Avoid generic names
Give names to magic numbers
Avoid too many nested levels
Avoid too many branches
Use “telephone test” for readability
Use idioms of the language
Avoid superficial comments
Add comments to explain complex piece of software
Avoid writing comments by writing code clearly
Avoid side effects
Try to make functions stateless
Let one function do one thing well
Write smaller functions - the 7 plus or minus 2 rule
Separate “what” from “how”
Don’t sacrifice clarity for efficiency
The Zen of Python

Speaker bio

Anand Chitipothu is co-founder of Pipal Academy. He has been using and teaching Python for about a decade. He is co-author of web.py, a micro web framwork in Python.

Anand has worked at Internet Archive and Stand Life Sciences.

Slides

https://speakerdeck.com/anandology/writing-beautiful-code

Comments

{{ gettext('Login to leave a comment') }}

{{ gettext('Post a comment…') }}
{{ gettext('New comment') }}
{{ formTitle }}

{{ errorMsg }}

{{ gettext('No comments posted yet') }}

Hosted by

PyCon Pune 2017 more