Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Secret Recipes of the Python Ninja

You're reading from   Secret Recipes of the Python Ninja Over 70 recipes that uncover powerful programming tactics in Python

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788294874
Length 380 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Cody Jackson Cody Jackson
Author Profile Icon Cody Jackson
Cody Jackson
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Working with Python Modules FREE CHAPTER 2. Utilizing the Python Interpreter 3. Working with Decorators 4. Using Python Collections 5. Generators, Coroutines, and Parallel Processing 6. Working with Python's Math Module 7. Improving Python Performance with PyPy 8. Python Enhancement Proposals 9. Documenting with LyX 10. Other Books You May Enjoy

Inline comments and the dir command


The simplest and most common way to document code is to simply add comments while writing the code. This can range from simple TODO reminders for the developers, to an explanation of why the developer coded something in a particular way.

As seen previously, comments in Python code start with a hash mark, #, and continue to the end of the line. Multi-line comments can be made by adding a hash mark at the beginning of each line, or triple quotation marks can be used instead. Keep in mind, though, that certain tools don't know about triple-quoted comments, so it's better to use them sparingly.

The problem with in-line comments is that they can only be seen if you are actively looking at the code. While we will discuss ways to access in-code comments, these basic one-liners are not actively culled by documentation parsers.

If, however, you want to see what functions a module provides to the developer, using the dir() function is one easy way of doing that. The...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime