Intro to Object-Oriented Python
Posted on Jun 22nd, 2022
Today, we’ll take a brief survey of classes and objects in Python to get us ready to take on Django.
Today’s topics
- Python Classes
- Instantiating an Object
- Attributes
- Instance Methods
- “Magic” Methods
🔎 Word Frency/Optional Project Retrospective
Please indicate your answers on this form.
- Something I learned by doing this project is…
- Something I want to understand better or know more about is…
- In this project, I was happy that I was able to…
🐍 Code Break
🎯 Project
For Thursday afternoon through the weekend, DUE MONDAY: [Link to turn in your deployed DjangoGirls blog project] (https://forms.gle/QAeQBJNMRoHxX8ik9)
- Thinkific Object Oriented Python -> end of unit (4 sections)
- DjangoGirls (English) or
- DjangoGirls (Español)
UPDATE: this was aspirational. Blackjack will NOT be due, but you are welcome to try it This week, we will be applying principles of Object Oriented Programming in Python to build a Blackjack card game. OO Blackjack in Python
🔖 Resources
Object-oriented
- Real Python - Object-Oriented Programming in Python 3
- A Byte of Python: OO
- Inheritance and Composition in Python OO
- OO-Programming – This is a chapter from a book called Beyond the Basic Stuff With Python by Al Sweigart. He has written a ton of great books on Python and makes them available to read for free online at inventwithpython.com. You might check out Automate the Boring Stuff with Python. It’s a fantastic beginner book.
Classes in Python
- Python Docs: Classes
- Python Docs: Clases
- StackOverflow: How do I design a class in Python?
- Special Methods (aka magic methods) in the Python Docs
- Nombres Especiales de Método
- A Guide to Python’s Magic Methods This is a great reference, but watch out! It was written for Python 2, so a few things may be different in Python 3.
Useful resources for debugging
- Scope of Variables in Python
- 🐛 Debugging Python For Fun & Profit (video)
- Code Style Checks in Python We installed
flake8
on the first day of this phase. This post gives you some detail about what it’s for and why you need it.
🦉 Code & Notes
- Jupyter Notebooks Notebooks 13-15
- Repl from class: Word Frequency OO