Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python for Secret Agents

You're reading from  Python for Secret Agents

Product type Book
Published in Aug 2014
Publisher
ISBN-13 9781783980420
Pages 216 pages
Edition 1st Edition
Languages
Author (1):
Steven F. Lott Steven F. Lott
Author Profile Icon Steven F. Lott
Steven F. Lott
Toc

Creating Python modules and applications


We relied heavily on modules in the Python library. Additionally, we added several packages, including Pillow and BeautifulSoup. The question should arise, can we create our own module?

The answer is, of course, yes. A Python module is simply a file. It turns out that each example script has been a module. We can look a little more deeply at how we can make our own modules of reusable programming. When we look at Python programs, we observe three kinds of files:

  • Library modules that are purely definitional

  • Application modules that do the real work of our applications

  • Hybrid modules that are both applications and can be used as libraries

The essential ingredient of creating a Python module is separating the real work of the top-level script from the various definitions that support this real work. All our examples of definitions have been functions created with the def statement. The other import examples of definitions are class definitions, which we...

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 $19.99/month. Cancel anytime