All types in Python have a class.
Classes define the structure and behavior of an object.
The class of an object is determined when the object is created and is almost always fixed for the lifetime of the object.
Classes are the key support for Object-Oriented Programming in Python.
Classes are defined using the class keyword followed by the class name, which is in CamelCase.
Instances of a class are created by calling the class as if it were a function.
Instance methods are functions defined inside the class which should accept an object instance called self as the first parameter.
Methods are called using the
instance.method()
syntax which is syntactic sugar for passing the instance as the formal self argument to the method.An optional special initializer method called
__init__()
can be provided which is used to configure the self object at creation time.The constructor calls the
__init__()
method if one is present.The
__init__()
method is not the constructor. The object has been already...
The Python Apprentice
By :
The Python Apprentice
By:
Overview of this book
Experienced programmers want to know how to enhance their craft and we want to
help them start as apprentices with Python. We know that before mastering Python you need to learn the culture and the tools to become a productive member of any Python project. Our goal with this book is to give you a practical and thorough introduction to Python programming, providing you with the insight and technical craftsmanship you need to be a productive member of any Python project. Python is a big language, and it’s not our intention with this book to cover everything there is to know. We just want to make sure that you, as the developer, know the tools, basic idioms and of course the ins and outs of the language, the standard library and other modules to be able to jump into most projects.
Table of Contents (21 chapters)
Title Page
Credits
About the Authors
www.PacktPub.com
Customer Feedback
Preface
Free Chapter
Getting started
Strings and Collections
Modularity
Built-in types and the object model
Exploring Built-in Collection types
Exceptions
Comprehensions, iterables, and generators
Defining new types with classes
Files and Resource Management
Unit testing with the Python standard library
Debugging with PDB
Afterword – Just the Beginning
Virtual Environments
Packaging and Distribution
Installing Third-Party Packages
Customer Reviews