x = 43; x += 1; print(f"Tuesday Tip #{x}")


Hi Reader, happy Tuesday!

My recent tips have been rather lengthy, so I'm going to mix it up with some shorter tips (like today's). Let me know what you think! 💬


🔗 Link of the week

A stealth attack came close to compromising the world's computers (The Economist)

If you haven't heard about the recent "xz Utils backdoor", it's an absolutely fascinating/terrifying story! In short, a hacker (or team of hackers) spent years gaining the trust of an open-source project by making helpful contributions, which eventually allowed them to smuggle a sophisticated, hidden exploit into the code.

Had a single developer at Microsoft not discovered the problem (in his spare time!), hackers would soon have gained secret access to hundreds of millions of computers, allowing them to steal private data from banks, governments, and more.

For more technical details, see this article from Ars Technica.


👉 Tip #44: Augmented assignment in Python

If you're new to Python (or programming in general), you might be confused by code like this:

x += 1

As long as x is a number, that code translates to:

x = x + 1

In other words, it's a concise way to increment the value of x by 1.

This is known as "augmented assignment," and there are actually a dozen other augmented assignment operators in Python. Here are the most common ones:

x -= 3 (translates to x = x - 3)

x *= 4 (translates to x = x * 4)

x /= 2 (translates to x = x / 2)

Under the hood, these statements call dunder methods such as __iadd__, __isub__, and so on, which means that their behaviors can be customized for different types of objects.

In case you're curious, the "i" in __iadd__ stands for "in-place" because it mutates the original object. As such, you may notice an unexpected behavior if you try to use these operations with Python lists.


👋 See you next Tuesday!

Did you like this week’s tip? Please forward it to a friend or share this link with your favorite online community. It really helps me out!

- Kevin

P.S. xkcd comes true (a reference to the link of the week)

Did someone AWESOME forward you this email? Sign up here to receive Data Science tips every week!

Learn Artificial Intelligence from Data School 🤖

Join 25,000+ intelligent readers and receive AI tips every Tuesday!

Read more from Learn Artificial Intelligence from Data School 🤖

Hi Reader, Until 8 PM ET tonight, you can get the All-Access Pass for $99: Here's everything you need to know: Access all existing courses for one year ($700+ value) Includes new courses launched during your subscription Includes e-book version of Master Machine Learning (coming soon) Additional discounts available Lock in this price forever 30-day refund policy Get the Pass for $99 Questions? Please let me know! - Kevin

Hi Reader, I wanted to share with you three limited-time resources for improving your Python skills... 1️⃣ Algorithm Mastery Bootcamp 🥾 Are you looking for an intense, 12-day Python bootcamp? My friend Rodrigo Girão Serrão is running a new Algorithm Mastery Bootcamp, and it starts in just 5 days! In the bootcamp, you'll solve 24 real programming challenges and participate in daily live sessions to discuss and compare solutions. It's a great way to strengthen your problem-solving muscles 💪 I...

Hi Reader, Last week, I launched the All-Access Pass, which gives you access to ALL of Data School's courses for one year. Through Black Friday, you can buy the pass for $99, after which the price will increase. Here are the included courses: Build an AI chatbot with Python ($9) Create your first AI app in 60 minutes using LangChain & LangGraph! ⚡ Build AI agents with Python ($99) Develop the skills to create AI apps that can think and act independently 🤖 Conda Essentials for Data Scientists...