Share
 

Hey Pythonista,

We're back from leave and diving in with 5 Python / developer / mindset nuggets. We hope you find them helpful!

But before we do, quick check: have you joined our growing Python community yet?

Hope you have or will, you can join for free here: https://pybites.circle.so/

1) LLMs are essentially next-token predictors

Ever wondered about function/tool calling with LLMs? Christo wrote an interest article about this topic.

Large Language Models (LLMs) do not inherently call functions or tools; instead, they predict the next sequence of tokens based on the provided input.

Function calling is achieved through an additional layer of software that interprets the LLM's output and executes functions accordingly.

By understanding and implementing this interaction pattern, it is possible to extend any LLM to simulate function calling capabilities, even if it doesn't natively support them.

There is no magic here, it's good old fashioned software development with some LLM magic sprinkled in.


2) Clean code tip: use constants over magic numbers

In order to write more readable and maintainable Python code, this week we spotlight a simple yet impactful practice: using constants instead of magic numbers.

Magic numbers are hard-coded values that appear in code without explanation. They can make code harder to understand and maintain, as their meaning and origin might not be immediately clear to someone else (or even to you after some time has passed).

Consider this common scenario: You're writing a script that should only execute on Mondays. You might check the current day of the week against a hard-coded value, like so:

from datetime import datetime

if datetime.now().weekday() == 0:  # Is it clear that 0 represents Monday?        print("Let's get this week started!")

While this works, the comparison == 0 lacks clarity. Is 0 Monday? Why 0?

This is where constants come in. By using the calendar module, we can make our code significantly more readable:

import calendar
from datetime import datetime

if datetime.now().weekday() == calendar.MONDAY:   
    print("Let's get this week started!")

By replacing the magic number 0 with calendar.MONDAY, we've made the code self-documenting. 😍

It's immediately clear to anyone reading this code that the condition checks for Monday. This practice reduces potential confusion and errors, making your code more robust and easier to maintain.

So, use constants for more readable and higher quality code.

See also our related YouTube video: https://www.youtube.com/watch?v=IljQqLnPC14

3) Unlock your golden ticket when it comes to networking

Discover the secret to accessing exclusive events without an invite!

This is just one of the fascinating stories Louise Oprel shares in our latest podcast.

Her volunteering work and how she levers it to enter prestigious gatherings, from international festivals to tech conferences, is inspiring.

She shares how this strategy, and adopting the right mindset, enriched her life with invaluable knowledge, experiences, and connections.

We also geek out over books and career :)


4) With Python you should not re-invent the wheel

I recently had to convert a bunch of articles into PDFs, a task that could involve quite some coding but thanks to some robust Python libraries I had this coded up in no time. Here's what I used:

  • Newspaper3k was key for pulling article content easily and reliably.

  • FPDF allowed for easy PDF creation, offering customization for titles and texts while managing character encoding.

  • ThreadPoolExecutor - from the concurrent.futures Standard Library module, shared in a previous email, significantly sped up the process, enabling parallel article processing.

This mini project highlighted the effectiveness of utilizing specialized Python libraries, saving time and avoiding unnecessary coding.

So just a reminder to leverage the vast number of powerful tools the Python ecosystem has to offer!

What are some awesome Python libraries you've recently used? Reply and let us know.

5) From the archives: Streamlit

Turn your idea into a reality with Streamlit 🚀

Marco Franzon's article from October 25, 2023, showcases Streamlit as a transformative tool for turning ideas into Minimum Viable Products (MVPs) with minimal coding.

Streamlit simplifies the creation of web applications for data science and machine learning, allowing innovators to quickly validate concepts with a functional prototype.

From installation to app creation with interactive elements, the article provides a step-by-step guide, exemplified by Marco's Dubbing AI project.

Embrace Streamlit for efficient idea validation and take your project from concept to reality with unprecedented ease.


Are you using Streamlit? Let us know or share a post in our community.

---

And talking about our community, make sure you join, it's totally free, and you can interact more with us, our team, and 690 (and growing) passionate Python developers!

Hope to see you there! 🐍 📈


Best,
Bob & Julian


P.S. we'd like to take a moment to celebrate PDM-er Andrew landing a new Data Engineer job! 🎉

In his win he called out how important it is to have goals and the right mindset.

If you feel stuck in your career, come talk to us!

We have developed a unique and effective method to get you to your goals fast.

Just imagine what doubling your skill levels can do for you personally: more pay, more impact with code / open source, start your own side gig, become your team's goto expert... just to name a few benefits.

Check out how we do this here:
https://pybit.es/catalogue/the-pdm-program/


Email Marketing by ActiveCampaign