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@pybites.bsky.social
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 ๐ 0I've completed "User input" on @pybites.bsky.social ๐๐ - pybitesplatform.com/bites/user-i...
06.06.2025 05:29 โ ๐ 2 ๐ 1 ๐ฌ 0 ๐ 0Tutorials 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
๐ Claim your spot at pybitescoaching.com
28.05.2025 10:44 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0Youโ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. ๐ช ๐
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...
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 ๐ 0I've completed "Pybites date generator" on @pybites.bsky.social ๐๐ - pybitesplatform.com/bites/pybite...
#python
๐จโ๐ซ 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
๐ 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 ๐ก)
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 ๐ 0You 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๐ฑ ๐ฐ๐ผ๐ผ๐น ๐๐ฎ๐๐ to use the underscore in #Python ๐๐ก
โข Ignore ๐๐ฎ๐น๐๐ฒ๐ when unpacking
โข Loop ๐ฝ๐น๐ฎ๐ฐ๐ฒ๐ต๐ผ๐น๐ฑ๐ฒ๐ฟ
โข Access ๐น๐ฎ๐๐ ๐ฟ๐ฒ๐๐๐น๐ in REPL
โข Format ๐น๐ฎ๐ฟ๐ด๐ฒ ๐ป๐๐บ๐ฏ๐ฒ๐ฟ๐
โข Define "๐ฝ๐ฟ๐ถ๐๐ฎ๐๐ฒ" methods (convention)
See below ๐
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 ๐
)
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:
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
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 ๐ 0Becoming 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
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
๐ ๐ช ๐ฅ
15.04.2025 12:04 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0from 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
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
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 ๐ชด
Who has experienced this?
#AI tools: quick wins, but more + longer debugging?
(image source: www.reddit.com/r/Programmer...)
"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! ๐
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
@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 ๐
# 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
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 ๐ก๐
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