's Avatar

@pybites.bsky.social

86 Followers  |  4 Following  |  23 Posts  |  Joined: 30.11.2024  |  2.0793

Latest posts by pybites.bsky.social on Bluesky

Post image

Heads up I am running another Snipster #Python training cohort next week - we'll build this cool app:

17.06.2025 12:32 โ€” ๐Ÿ‘ 1    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Preview
Pybites Platform | Master Python Through Hands-On Coding Overwhelmed by tutorials? Stop consuming books and courses! Confidence will come through a lot of deliberate practice. Our platform helps you master Python and grasp Pythonic best practices.

I've completed "User input" on @pybites.bsky.social ๐Ÿ๐ŸŽ‰ - pybitesplatform.com/bites/user-i...

06.06.2025 05:29 โ€” ๐Ÿ‘ 2    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

Tutorials are clean โ€” but real code is messy. ๐Ÿ’ก

Our coaching cohort helps you thrive in the wild ๐Ÿ’ช
โ€ข write tests, refactor with confidence
โ€ข debug real issues
โ€ข build an efficient dev toolkit
โ€ข collaborate using Git/GitHub
โ€ข ship code youโ€™re proud of

๐Ÿ‘‰ pybitescoaching.com

#Python #Developer

30.05.2025 13:37 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Pybites Developer Cohort (PDC) Coaching

๐Ÿ‘‰ Claim your spot at pybitescoaching.com

28.05.2025 10:44 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

Youโ€™ve done 100 Python ๐Ÿ exercises. Now what? ๐Ÿค”

Building a real app still feels out of reach. ๐Ÿ˜ฎ

Thatโ€™s where our cohorts come in - we guide you from confusion to confidence, project by project. ๐Ÿ’ช ๐Ÿš€

28.05.2025 10:42 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Pybites Podcast 191: Code, click, cloud - how Sebastiรกn Ramรญrez is taking FastAPI to the next level
YouTube video by Pybites Pybites Podcast 191: Code, click, cloud - how Sebastiรกn Ramรญrez is taking FastAPI to the next level

Thanks for joining us ๐ŸŽง @tiangolo.com ๐ŸŽ‰ and for all you do with @fastapi.tiangolo.com, other libs, and now FastAPI Cloud ๐Ÿ˜

It will be so nice to deploy FastAPI apps with just: `fastapi deploy` ๐Ÿš€

www.youtube.com/watch?v=Q_8a...

27.05.2025 17:13 โ€” ๐Ÿ‘ 5    ๐Ÿ” 2    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 1
Preview
Pybites Platform | Master Python Through Hands-On Coding Overwhelmed by tutorials? Stop consuming books and courses! Confidence will come through a lot of deliberate practice. Our platform helps you master Python and grasp Pythonic best practices.

I've completed "Build unix' wc program in python" on @pybites.bsky.social ๐Ÿ๐ŸŽ‰ - pybitesplatform.com/bites/build-...

27.05.2025 17:11 โ€” ๐Ÿ‘ 1    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Preview
Pybites Platform | Master Python Through Hands-On Coding Overwhelmed by tutorials? Stop consuming books and courses! Confidence will come through a lot of deliberate practice. Our platform helps you master Python and grasp Pythonic best practices.

I've completed "Pybites date generator" on @pybites.bsky.social ๐Ÿ๐ŸŽ‰ - pybitesplatform.com/bites/pybite...

#python

09.05.2025 15:48 โ€” ๐Ÿ‘ 1    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

๐Ÿ‘จโ€๐Ÿซ Want in?

The main cohort is full, but beginner spots are still open (or join the waiting list for the next intermediate one)

Check it out here ๐Ÿ‘‰ pybitescoaching.com

06.05.2025 16:43 โ€” ๐Ÿ‘ 1    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image Post image

๐Ÿš€ Built a #Streamlit front-end on top of a #FastAPI backend for our next cohort (starting next week!) ๐Ÿš€

Great stack for quickly prototyping a front-end, all #Python, no JS ๐Ÿ˜Ž

(For more serious web apps you definitely want JS and/or htmlx though ๐Ÿ’ก)

06.05.2025 16:43 โ€” ๐Ÿ‘ 2    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

Learn more advanced and real world #python #developer techniques - join us for our first 6 week intermediate cohort 12th of May ๐ŸŽ‰ ๐Ÿ ๐Ÿ’ช

29.04.2025 07:57 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Preview
Pybites Platform | Master Python Through Hands-On Coding Overwhelmed by tutorials? Stop consuming books and courses! Confidence will come through a lot of deliberate practice. Our platform helps you master Python and grasp Pythonic best practices.

You pick up dozens of these small and subtle #python ๐Ÿ tricks + idioms when you make it a habit to code on our platform every day ๐Ÿ’ก ๐Ÿ”ฅ -> join here: pybitesplatform.com ๐Ÿ“ˆ

25.04.2025 14:05 โ€” ๐Ÿ‘ 1    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

๐Ÿฑ ๐—ฐ๐—ผ๐—ผ๐—น ๐˜„๐—ฎ๐˜†๐˜€ to use the underscore in #Python ๐Ÿ๐Ÿ’ก

โ€ข Ignore ๐˜ƒ๐—ฎ๐—น๐˜‚๐—ฒ๐˜€ when unpacking

โ€ข Loop ๐—ฝ๐—น๐—ฎ๐—ฐ๐—ฒ๐—ต๐—ผ๐—น๐—ฑ๐—ฒ๐—ฟ

โ€ข Access ๐—น๐—ฎ๐˜€๐˜ ๐—ฟ๐—ฒ๐˜€๐˜‚๐—น๐˜ in REPL

โ€ข Format ๐—น๐—ฎ๐—ฟ๐—ด๐—ฒ ๐—ป๐˜‚๐—บ๐—ฏ๐—ฒ๐—ฟ๐˜€

โ€ข Define "๐—ฝ๐—ฟ๐—ถ๐˜ƒ๐—ฎ๐˜๐—ฒ" methods (convention)

See below ๐Ÿ‘‡

25.04.2025 14:05 โ€” ๐Ÿ‘ 2    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image

Potentially underused #Python ๐Ÿ feature: ๐˜€๐—ฒ๐˜ ๐—ผ๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐Ÿ’ก

Here's an example how we can remove or update tags, casting new + old into sets, then performing ๐˜ด๐˜ฆ๐˜ต ๐˜ฐ๐˜ฑ๐˜ฆ๐˜ณ๐˜ข๐˜ต๐˜ช๐˜ฐ๐˜ฏ๐˜ด ๐Ÿ”ฅ

Have you used them, how? ๐Ÿ˜

(Still on the fence about ๐˜ธ๐˜ข๐˜ญ๐˜ณ๐˜ถ๐˜ด, but couldn't bear doing ๐˜ด๐˜ต๐˜ณ๐˜ช๐˜ฑ() twice ๐Ÿ˜…)

25.04.2025 06:16 โ€” ๐Ÿ‘ 3    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
import os
from pathlib import Path
from tempfile import TemporaryDirectory

import pytest


def count_dirs_and_files(directory_path: str = '.' ) -> tuple[int, int]:
    """Function for counting dirs and files in a directory."""
    dirs, files = 0, 0
    for _, directories, filenames in os.walk(directory_path):
        dirs += len(directories)
        files += len(filenames)
    return dirs, files


def test_only_files():
    with TemporaryDirectory(dir="/tmp") as dirname:
        for i in range(1, 6):
            (Path(dirname) / f'{i}.txt').write_text('hello')
        assert count_dirs_and_files(dirname) == (0, 5)

# refactored using pytest's tmp_path fixture + parametrize

@pytest.mark.parametrize("num_files", [1, 5, 10])
def test_only_files_param(tmp_path, num_files):
    for i in range(1, num_files + 1):
        (tmp_path / f'{i}.txt').write_text('hello')
    assert count_dirs_and_files(tmp_path) == (0, num_files)

import os from pathlib import Path from tempfile import TemporaryDirectory import pytest def count_dirs_and_files(directory_path: str = '.' ) -> tuple[int, int]: """Function for counting dirs and files in a directory.""" dirs, files = 0, 0 for _, directories, filenames in os.walk(directory_path): dirs += len(directories) files += len(filenames) return dirs, files def test_only_files(): with TemporaryDirectory(dir="/tmp") as dirname: for i in range(1, 6): (Path(dirname) / f'{i}.txt').write_text('hello') assert count_dirs_and_files(dirname) == (0, 5) # refactored using pytest's tmp_path fixture + parametrize @pytest.mark.parametrize("num_files", [1, 5, 10]) def test_only_files_param(tmp_path, num_files): for i in range(1, num_files + 1): (tmp_path / f'{i}.txt').write_text('hello') assert count_dirs_and_files(tmp_path) == (0, num_files)

Making a temporary file/dur is very useful for ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด.

In the example below, we first use ๐˜›๐˜ฆ๐˜ฎ๐˜ฑ๐˜ฐ๐˜ณ๐˜ข๐˜ณ๐˜บ๐˜‹๐˜ช๐˜ณ๐˜ฆ๐˜ค๐˜ต๐˜ฐ๐˜ณ๐˜บ to create 5 temp files.

This is a great example of using a ๐—ฐ๐—ผ๐—ป๐˜๐—ฒ๐˜…๐˜ ๐—บ๐—ฎ๐—ป๐—ฎ๐—ด๐—ฒ๐—ฟ โ€” a clean way to automatically clean up resources.

pytest makes it even easier using the ๐˜ต๐˜ฎ๐˜ฑ_๐˜ฑ๐˜ข๐˜ต๐˜ฉ fixture:

23.04.2025 09:14 โ€” ๐Ÿ‘ 3    ๐Ÿ” 2    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image

Do you know all these 5 powerful uses of * in #Python?

โ€“ Keyword-only args
โ€“ Extended unpacking
โ€“ Flexible funcs with *args
โ€“ Unpack into func calls
โ€“ Merge iterables

๐Ÿ‘‡ See examples below โ€” which ones do you use the most, and which ones are new to you?

#coding #tips

18.04.2025 08:37 โ€” ๐Ÿ‘ 4    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Preview
Enhance Your Developer Mindset - Join Our Pybites Newsletter - Pybites ๐Ÿ Elevate your Python, developer and mindset skills. Every week, for free!

Keep up2date with relevant #Python developer tips + industry trends joining our weekly @pybites.bsky.social Newsletter: pybit.es/newsletter ๐Ÿ’ก ๐Ÿš€

16.04.2025 08:56 โ€” ๐Ÿ‘ 5    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image Post image

Becoming a proficient #Python dev isnโ€™t just about syntax, itโ€™s about building usable apps with clean, testable, well-structured code.

Thatโ€™s what we coach in our 6-week cohort starting next month.

Real apps. Real feedback. Real growth. ๐Ÿ’ช

More info: pybitescoaching.com

17.04.2025 15:19 โ€” ๐Ÿ‘ 4    ๐Ÿ” 2    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

A common #Polars saying:

"๐™„ ๐™˜๐™–๐™ข๐™š ๐™›๐™ค๐™ง ๐™ฉ๐™๐™š ๐™จ๐™ฅ๐™š๐™š๐™™, ๐™—๐™ช๐™ฉ ๐™จ๐™ฉ๐™–๐™ฎ๐™š๐™™ ๐™›๐™ค๐™ง ๐™ฉ๐™๐™š ๐™จ๐™ฎ๐™ฃ๐™ฉ๐™–๐™ญ" ๐Ÿ˜

I see why now โ€” it's ๐—ฏ๐—ฒ๐—ฎ๐˜‚๐˜๐—ถ๐—ณ๐˜‚๐—น and ๐—ณ๐—ฎ๐˜€๐˜. ๐Ÿ“ˆ

Switched from Pandas?
Whatโ€™s been your biggest win (or pain)? ๐Ÿค”

#Python #Rust #DataAnalytics

16.04.2025 08:35 โ€” ๐Ÿ‘ 6    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

๐ŸŽ‰ ๐Ÿ’ช ๐Ÿ”ฅ

15.04.2025 12:04 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
from itertools import combinations
from difflib import SequenceMatcher

tags = ['python', 'pythonista', 'developer', 'development', 'dev', 'devs']

def similar(a: str, b: str) -> float:
    return SequenceMatcher(None, a, b).ratio()

THRESHOLD = 0.8  # tune based on how strict you want to be

for a, b in combinations(tags, 2):
    score = similar(a, b)
    if score >= THRESHOLD:
        print(f"{a} โ‰ˆ {b} โ†’ {score:.2f}")

# output:
# developer โ‰ˆ development โ†’ 0.80
# dev โ‰ˆ devs โ†’ 0.86

from itertools import combinations from difflib import SequenceMatcher tags = ['python', 'pythonista', 'developer', 'development', 'dev', 'devs'] def similar(a: str, b: str) -> float: return SequenceMatcher(None, a, b).ratio() THRESHOLD = 0.8 # tune based on how strict you want to be for a, b in combinations(tags, 2): score = similar(a, b) if score >= THRESHOLD: print(f"{a} โ‰ˆ {b} โ†’ {score:.2f}") # output: # developer โ‰ˆ development โ†’ 0.80 # dev โ‰ˆ devs โ†’ 0.86

De-duped our books category page by reconciling similar titles, e.g.

think & grow rich โ†’ think and grow rich
everything is f*cked โ†’ everything is # @%!ed

Just stdlib -> `difflib`, no external deps ๐Ÿš€

(Fun fact: Djangoโ€™s manage.py uses this too btw ๐Ÿ˜Ž)

#python #tips

14.04.2025 08:56 โ€” ๐Ÿ‘ 3    ๐Ÿ” 1    ๐Ÿ’ฌ 2    ๐Ÿ“Œ 0
from dataclasses import dataclass

@dataclass
class Bite:
    number: int
    title: str
    description: str

    def __post_init__(self):
        self.number = int(self.number)
        self.title = self.title.strip().title()
        self.description = self.description.strip()
        if not 5 < len(self.title) < 20:
            raise ValueError("Title must be between 5 and 20 characters long")
        if self.number <= 0:
            raise ValueError("Number must be a positive integer")

bite = Bite(1, "  example title  ", "This is a description.")
# Bite(number=1, title='Example Title', description='This is a description.')
bite = Bite(2, "this title is waaaaaaaaaaaay too long", "This is a description.")
# ValueError: Title must be between 5 and 20 characters long
bite = Bite(-1, "another title", "blabla")
# ValueError: Number must be a positive integer

from dataclasses import dataclass @dataclass class Bite: number: int title: str description: str def __post_init__(self): self.number = int(self.number) self.title = self.title.strip().title() self.description = self.description.strip() if not 5 < len(self.title) < 20: raise ValueError("Title must be between 5 and 20 characters long") if self.number <= 0: raise ValueError("Number must be a positive integer") bite = Bite(1, " example title ", "This is a description.") # Bite(number=1, title='Example Title', description='This is a description.') bite = Bite(2, "this title is waaaaaaaaaaaay too long", "This is a description.") # ValueError: Title must be between 5 and 20 characters long bite = Bite(-1, "another title", "blabla") # ValueError: Number must be a positive integer

Pydantic is awesome for data cleaning + validation, but if you want something quick + stdlib only, you can also use dataclasses + `__post_init__` ๐Ÿ ๐Ÿ˜ - see example below. ๐Ÿš€

#python #tips

11.04.2025 09:40 โ€” ๐Ÿ‘ 8    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

Feel like my Python is getting rusty with AI finishing all myโ€ฆ sentences.
Doing some code challenges on @pybites.bsky.social with no code completions as nature intended ๐Ÿชด

08.04.2025 07:15 โ€” ๐Ÿ‘ 6    ๐Ÿ” 2    ๐Ÿ’ฌ 2    ๐Ÿ“Œ 0
Post image

Who has experienced this?

#AI tools: quick wins, but more + longer debugging?

(image source: www.reddit.com/r/Programmer...)

02.04.2025 11:52 โ€” ๐Ÿ‘ 5    ๐Ÿ” 2    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

"The only way to learn a new programming language is by writing programs in it." โ€“ Dennis Ritchie

No CS degree. Went from Excel macros to #Python ๐Ÿš€

Code wasnโ€™t that clean at first, but by building a real-world solution I launched my dev career ๐Ÿ’ก

Build first, polish later! ๐Ÿ“ˆ

21.03.2025 18:32 โ€” ๐Ÿ‘ 7    ๐Ÿ” 2    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
import sys, time

start = time.time()
list_comp = [x for x in range(100_000_000)]
print(f"List: {sys.getsizeof(list_comp):,} bytes, {time.time() - start:.4f}s")

start = time.time()
gen_exp = (x for x in range(100_000_000))
print(f"Generator: {sys.getsizeof(gen_exp):,} bytes, {time.time() - start:.4f}s")

import sys, time start = time.time() list_comp = [x for x in range(100_000_000)] print(f"List: {sys.getsizeof(list_comp):,} bytes, {time.time() - start:.4f}s") start = time.time() gen_exp = (x for x in range(100_000_000)) print(f"Generator: {sys.getsizeof(gen_exp):,} bytes, {time.time() - start:.4f}s")

List vs Generator in Python ๐Ÿ๐Ÿ’ก

List: 835MB, 0.99s
Generator: 192B, 0.00s ๐Ÿ˜ฒ

โ€ข Use `sys.getsizeof()` to check memory.
โ€ข Use generators when you donโ€™t need all values at once.

Small change, big difference! ๐Ÿ“ˆ

#Python #tips #performance

20.03.2025 07:59 โ€” ๐Ÿ‘ 4    ๐Ÿ” 2    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image

@Pybites Books v2 is live! ๐Ÿš€

Simple, fast book tracking that incentivizes you to keep #reading ๐Ÿ˜Ž

Gamified, clean design (Tailwind + Htmx ๐Ÿ™), and loved by users already. ๐Ÿ˜

Letโ€™s keep #books alive ๐Ÿ’ก, especially in this day and age. ๐Ÿ“ˆ

Try it โ†’ pybitesbooks.com ๐Ÿ“š

19.03.2025 15:13 โ€” ๐Ÿ‘ 1    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
# js
console.log(1 + "2"); // Outputs "12" ๐Ÿคฏ 

#ย py
1 + "2"  # TypeError
str(1) + "2"  # "12"

# js console.log(1 + "2"); // Outputs "12" ๐Ÿคฏ #ย py 1 + "2" # TypeError str(1) + "2" # "12"

"In the face of ambiguity, refuse the temptation to guess." ๐Ÿ’ก

Python prefers clarity over assumptions:
โ€ข No implicit type coercion
โ€ข One null: None
โ€ข Mandatory indentation = no dangling if
โ€ข Type hints + mypy = catch bugs early

>>> import this ๐Ÿ

#Python #DevTips #Coding

18.03.2025 08:18 โ€” ๐Ÿ‘ 4    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

Elegant API design in #Python libs ๐Ÿ

โ€ข requests/httpx: no auto errors, you call raise_for_status() โ†’ full control

โ€ข newspaper3k: download(), parse(), nlp() โ†’ as needed

โ€ข pathlib.Path: / operator + chaining methods โ†’ clean, OOP fs access

Great libs donโ€™t box you in ๐Ÿ’ก๐Ÿš€

17.03.2025 16:35 โ€” ๐Ÿ‘ 3    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image

Subclassing dict or list in Python? Beware! ๐Ÿ˜ฑ Some built-in methods bypass your overrides.

โœ… Use collections.UserDict & UserList instead! They ensure all operations respect your methods.

๐Ÿš€ Cleaner, predictable behavior.

#Python #tips

14.03.2025 15:34 โ€” ๐Ÿ‘ 4    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

@pybites is following 4 prominent accounts