Share
 

Hey Pythonista,

Happy Tuesday! We've distilled some good Python, developer and mindset lessons this week - ready? Let's go!

1) Quote to ponder

We recently stumbled upon a gem of a quote by Patrick McKenzie that really resonated with us:

"Every great developer you know got there by solving problems they were unqualified to solve until they actually did it."

This strikes at the heart of what we've always believed and built Pybites around: to challenge you with real-world Python problems that stretch your skills and push you out of your comfort zones, which is necessary for growth.

Just remember, every piece of code you write, every error you debug, and every challenge you conquer brings you one step closer to becoming the developer you aspire to be.

Often you have to "fake it a little before you make it", but in the end, it's about embracing the discomfort, diving into the unknown, and transforming those "unqualified" moments into triumphs of learning and growth.

Keep coding, keep growing, and let's continue to tackle those challenges together.

If you struggle with anything leverage our community which you can join for free here: https://pybites.circle.so/

2) Python tip

As you probably know Python dataclasses automate object construction, so you don't need to write an `__init__` method. 🎉

But what if you do want to do some extra initialization?

Use the  `__post_init__` method. 📈

Of course, when this gets involved consider using Pydantic instead. 💡

from datetime import datetime
from dataclasses import dataclass, field

MAX_CONTENT_LENGTH = 280

@dataclass
class XPost:
    content: str
    author: str
    timestamp: str | None = field(default=None)
    hashtags: list[str] = field(default_factory=list)

    def __post_init__(self):
        if len(self.content) > MAX_CONTENT_LENGTH:
            raise ValueError("Content too long")

        if self.timestamp is None:
            self.timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

        self.hashtags = [f"#{tag.lstrip('#')}" for tag in self.hashtags]

post = XPost(content="Python dataclasses are so nice!",
             author="bbelderbos",
             hashtags=["python", "coding", "#tips"])
print(post)
# XPost(content='Python dataclasses are so nice!', author='bbelderbos',
# timestamp='2024-02-23 14:53:22', hashtags=['#python', '#coding', '#tips'])


...dataclass, namedtuple, attrs, Pydantic... we're working on an article to keep them apart, stay tuned.

3) Our podcast helps breaking mindset barriers 💪

From procrastinating and almost not launching our podcast 3 years ago to an important piece in the developer mindset puzzle...

We wanted to share this amazing feedback we received last week regarding our show:

> I like the obvious advantage of your podcast which is the focus on the developer mindset. It helped me a lot in this short period of time I've been listening. I'm now more relaxed when I try to build my projects knowing that everything will take its course and I don't have to think of all the details of things that need to be done in the entire project. Instead, I focus only on the problem at hand, solve it, and move the next. Also now, I'm more convinced that I don't have to write perfect code from the start. I used to be overwhelmed by the idea that my solution is not the best out there and that "pros" would write a more pythonic and cleaner code than what could write which is not exactly true. The more I look at, say, popular libraries' code, the more I know it's become that good only over time and after a lot of iterations not necessarily from the first time. All that's to say I can already feel the impact of the podcast on my mindset.

If you struggle with perfectionism, imposter syndrome, and other mindset barriers make sure you tune in here: https://www.pybitespodcast.com

This week we have an exciting guest for you, Mike Fiedler, in charge of PyPI's security. 😎 🔥

Interesting and insightful interview! Make sure you're subscribed to the podcast on your favorite app to be notified when it drops.

4) Mindset tip: embrace the power of walking away!

When tackling tough coding challenges, incessant effort isn't always the answer.

A strategic retreat, like a short walk or a different activity, can shift your mind into a state conducive to creative breakthroughs.

This approach, highlighted in Russell Helmstedter's experience with a perplexing coding issue, underscores the power of giving your brain a rest to gain fresh perspectives.

His story, detailed in "Stuck in import hell? Walk your way out", serves as a potent reminder: stepping back can be as crucial as pushing forward, especially in the tech world where persistence often meets dead ends. Embrace the pause; it might just lead you to the solution you've been searching for.


This mindset shift could be your key to unlocking productivity and innovation.

Remember, the solution might just be a walk away.

5) From the archives

Last year Antonio Melé and Bob discussed a ton of cool must-use Django plugins 💪 💡

Django Debug Toolbar, Django REST Framework, Django Channels, Django Celery, Django Extensions, Django allauth and social-auth, Django Import Export, Django Sentry, Django Easy Thumbnails / Imagekit, and Django-parler:


---

That's it. We hope these 5 nuggets help you in your developer journey this week!

Never hesitate to hit us up in our community.


Best,

Bob & Julian


Email Marketing by ActiveCampaign