
Giving life-long learners a low-stress way to hone their #Python skills. 🐍🍪 Write beautiful code. ✨ Made by @treyhunner 💖
Joined January 2018
- Tweets1.5K
- Following5
- Followers6.8K
- Likes58
Python Morsels retweeted
The #Python Morsels lifetime access sale ends tomorrow. ⏰
If you enjoy my teaching style and you plan to use Python frequently during the next few years, consider getting lifetime access to @PythonMorsels. 🐍💖
pym.dev/lifetime
Python Morsels retweeted
I'm doing something I've never done: I'm offering lifetime access to #Python Morsels. ♾️
You can get access to all screencasts, articles, and exercises I publish for the price of a 2 year subscription. 🐍
This sale ends on November 27, 2023 💸
pythonmorsels.com/lifetime-a…
Python Morsels retweeted
I've been running a #Python programming exercise service for nearly 6 years.
Here's my advice for how to go about solving a #programming exercise to minimize time and maximize effective learning.
pym.dev/programming-exercise…
Python Morsels retweeted
If you have a #Python Morsels subscription, check your email! 💌
I sent you a preview of this year's Cyber Monday sale with an extra subscriber discount.
If you're not a @PythonMorsels subscriber yet, get my newsletter to hear the announcement soon! 💸
pym.dev/newsletter
Python Morsels retweeted
"In Python, empty objects are falsey. For objects that have a length, if their length is greater than zero, they're considered truthy. And objects with a length equal to zero are falsey." #Python 🪞🐍
pythonmorsels.com/truthiness…
Python Morsels retweeted
"Whenever you call a class, #Python will construct a new instance of that class, and then call that class' __init__ method" 🐍🆕
pythonmorsels.com/what-is-in…
Python Morsels retweeted
Dunder (__dunder__) methods act as a contract between the #Python interpreter and the person who made a particular Python class.
Operators, built-in functions, and some special syntaxes are all powered by dunder methods.
pythonmorsels.com/topics/wha…
Python Morsels retweeted
"Iterables might not have a length and you might not be able to index them. They might not even be finite (there are infinitely long iterables in Python)!" #Python
pythonmorsels.com/iterable/?…
Python Morsels retweeted
What is a list comprehension in #Python? What are they used for and how are they different from a for loop?
pythonmorsels.com/topics/wha…
Python Morsels retweeted
Python Morsels Lite subscribers get a new screencast recommendation every week and a new #Python exercise every month.
It's just $14/month.
Sign up to try out a few free exercises and decide whether it's right for you.
pym.dev/watch-python-screenc…
Python Morsels retweeted
Reading tracebacks is just part of the process of writing Python code. 📗
Whenever #Python encounters an unhandled exception in your code, it'll print out a traceback. 🐞
pythonmorsels.com/reading-tr…
Python Morsels retweeted
Need an attribute that updates its value automatically? Use a property!
In the #Python world, we tend to prefer properties over getter methods.
pythonmorsels.com/topics/mak…
Python Morsels retweeted
"Thanks to duck typing, any object that can be looped over with a for loop or with a comprehension can also be looped over with the built-in list constructor: an iterable is an iterable."
pym.dev/using-list/?utm_camp…
Python Morsels retweeted
3 minute screencast on how to write a "for loop" in Python:
pythonmorsels.com/topics/wri…
Unlike traditional C-style "for loops", #Python's "for loops" don't have indexes (and it's a best practice to avoid reaching for indexes unless you really need them).
Python Morsels retweeted
Python's data structures don't contain objects; they contain pointers to objects 😮🐍
This screencast contains an odd proof of this:
>>> x = []
>>> x.append(x)
>>> x[0][0][0][0][0] is x
True
pythonmorsels.com/topics/dat…
Python Morsels retweeted
Define a __repr__ on all your classes. All #Python objects should have a nice string representation.
You'll rarely want to define a __str__ method.
pythonmorsels.com/topics/cus…
Python Morsels retweeted
In #Python, everything is an object.
Classes are objects. Modules are objects. Functions are objects. In fact, they're all mutable objects!
pym.dev/everything-is-an-obj…
Python Morsels retweeted
"While deciphering tracebacks, keep in mind that the line number is just Python's best guess as to where the error occurred."
pym.dev/syntaxerror-invalid-…
Python Morsels retweeted
Is your #Python program printing out a traceback? You have an uncaught exception!
You can catch that exception with a try-except block.
trey.io/qQDGls
Python Morsels retweeted
"If we run our #Python file from the command line, __name__ will be the string __main__. "
pym.dev/making-main-function…

