python

Back Open Paginator
25.09.2025 01:00
leanpub (@leanpub@mastodon.social)

15 Cheat Sheet Collection in Python + Git + NumPy + ML + Mindset by Christian Mayer is free with a Leanpub Reader membership! Or you can buy it for $7.99! leanpub.com/python-cheat-sheet




Show Original Post


25.09.2025 00:20
AdamOnza (@AdamOnza@mastodon.online)

For around 13 years, I've "maintained" my own Wireworld simulator in #Python. It has become quite a monster. I want to reuse bits of it, but separating them from the main, amorphous mass is difficult. So I have shirked it for- around 13 years... Though it did get converted to Python 3.

I think I might just have to make new code inspired by it.😅




Show Original Post


25.09.2025 00:07
diazona (@diazona@techhub.social)

@stylus Maybe look into typing.TypeGuard or its newer alternative typing.TypeIs. They're documented in the stdlib typing module.

IMO casting is also a totally reasonable approach in this situation. Casting is just how you give the type checker information that it can't infer on its own. Obviously not to be overused, but sometimes it's necessary and appropriate.

#Python




Show Original Post


24.09.2025 23:58
driscollis (@driscollis@mastodon.social)

Need to time how long a short snippet of code takes to run? Use the timeit module! 🐍🔥

You can also use timeit to time functions and imports!





Show Original Post


24.09.2025 23:43
stylus (@stylus@social.afront.org)

I have a Python static typing conundrum. I'd like a solution that works with mypy.

I have a function which fills out a list, albeit not "in order", so it's inconvenient to write it as a list comprehension or similar.

So, I fill the list with [None] and assert that all the Nones are gone by the time it returns.

However, the assertion I wrote does NOT convince mypy that the type of result now matches the return type of f, and I get a diagnostic: Incompatible return value type (got "list[int | None]", expected "list[int]")

def f() -> list[int]:
result: list[int|None] = [None] * 3
result[0] = 1
result[2] = 2
result[1] = 3
assert not any(i is None for i in result)
return result

Any hints? Can I do something besides cast the return value?

#askMastodon #python #mypy




Show Original Post


24.09.2025 23:01
adam_jurkiewicz (@adam_jurkiewicz@linux.social)

#Python #OpenCV w akcji, #PyCharm w trybie #Debug pomaga w wyjaśnianiu...





Show Original Post


24.09.2025 22:33
pouyllau (@pouyllau@mastodon.social)

Dans la suite de mon texte et revue de code sur les technologies RAG. Je suis en train de porter le code du notebook vers des applications en y ajoutant sans doute l'indexation et traitement de l’epub. Je dois dire que les étapes du portage sont très instructives sur la ≠ « travail pour soi vs travail pour les autres. »




Show Original Post


24.09.2025 22:11
willmcgugan (@willmcgugan@mastodon.social)

One-shotting a prompt with Toad and Gemini to generate a Mandelbrot set.





Show Original Post


24.09.2025 22:10
aslankemalaslan (@aslankemalaslan@mastodon.online)

itch.io da PyGame Oyunu ararken bunu buldum! Trayıcıdan da oynanabiliyor!

Daha geliştirme aşamasında.

*******
Tarayıcınızda Hemen Oynamak İçin Bu Linke Tıklayın: hubertrex.github.io/pygame-ce-
*******

#PyGame #Python #Game
_______
• Pygame-CE web şablonu: hubertnafalski.itch.io/pygame-
• HubertReX / pygame-ce-web-boilerplate: github.com/HubertReX/pygame-ce





Show Original Post


24.09.2025 22:05
MarcelJan (@MarcelJan@mastodon.nl)

@diazona I even got Illegal instruction on my test Raspberry Pi with the 13.3 inch e-ink display. But I have found that the Illegal instruction comes from pyarrow and by downgrading it to a version between 20 and 21, the error no longer appears.

I've managed to get my #Python code running without errors again. Only I don't see the #eink display being updated. (I've had that problem with the new 13.3 inch before)

The story continues, because .. it's bedtime again. So small steps every evening.




Show Original Post


24.09.2025 21:50
HongPong (@HongPong@mastodon.social)

The ice scraper program is evolving quickly thanks to volunteer excellence. it includes more than 190 facilities and expanding highly detailed detainee data. the scraper- the code => github.com/Open-Security-Mappi




Show Original Post


24.09.2025 21:16
TechKeysX (@TechKeysX@mastodon.social)

S1 EP3 T1 - Machine Learning in Python Split Your Data for Training and Testing





Show Original Post


1 ...1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 ...1556
UP