Skip to content

Tags

#python

Python for scripts, services, data and machine learning: libraries, packaging, typing and performance.

23 posts

Posts tagged #python

  1. Question

    my snake game snake doesnt die when it eats itself?? kya galat hai 😅

    bhaiya didi help 😅 i made snake game in python (pygame) at night after physics. its working mostly but when snake eats itself it doesnt die?? it just goes through itself like ghost. kya ye sahi hai?? my friend says my snake is immortal lol here is the code (food wala part i removed to make it short, when it eats food i do snake_len += 1) import pygame pygame.init() win = pygame.display.set_mode((600, 400)) clock =…

    Aman Raj9likes11comments

  2. Update

    hostel mein sab cricket match dekh rahe the, main snake…

    hostel mein sab cricket match dekh rahe the, main snake game mein score counter bana raha tha. 3 ghante laga. counter ab kaam karta hai!! bas snake khud ko khaata hai toh score 0 nahi hota 😅 match kaun jeeta kisi ko pata hai?? kal physics test hai, mummy ko mat batana

    Aman Raj8likes7comments

  3. Question

    ayuda xq mi lista original cambia si modifiqué la copia?? (es tarea, lo admito)

    q onda, es para una tarea de estructuras de datos, no quiero q me la hagan solo entender q pasa jsjsjs matriz = [[0, 0], [0, 0]] copia = matriz copia[0][0] = 5 print(matriz) # [[5, 0], [0, 0]] ?????? despues lei q se usa .copy() y lo cambie: copia = matriz.copy() copia[0][0] = 5 print(matriz) # [[5, 0], [0, 0]] OTRA VEZ alv xq pasa esto si ya use copy?? el profe dijo algo de "referencias" pero no le entendi

    Emiliano Cruz3likes8comments

  4. Experience

    My grandson and I built a weather station on the terrace. He wrote the Python, I wrote the SQL, and the rain did the rest.

    Dear friends, Some of you have read my long stories about the bank. This one is shorter, and happier, and I hope you will forgive an old man for being a little proud. My grandson Vignesh is fourteen. He lives with us in Chennai while his parents work in Bengaluru, and for most of last year our relationship consisted of me asking him to put his phone down and him explaining to me, very patiently, that Python is…

    S. Ramanathan104likes35comments

  5. Question

    Respected members, why does my Python function remember the old list?

    Respected members, I am a mathematics teacher learning Python so that I can teach my Class 9 students properly. I wrote a small function to collect marks, and something very strange is happening. Kindly see: def add_mark(mark, marks=[]): marks.append(mark) return marks print(add_mark(45)) # [45] print(add_mark(78)) # [45, 78] I expected [78] print(add_mark(62)) # [45, 78, 62] Each time I call the function without…

    Lakshmi Prasad14likes8comments

  6. Question

    Django REST Framework: still N+1 queries after select_related, what am I missing?

    One of my mentees brought this to me and now I am also stuck, which is humbling. We have a simple endpoint listing courses. Each course has a teacher (ForeignKey) and many tags (ManyToMany), and the serializer also shows how many students are enrolled. class CourseSerializer(serializers.ModelSerializer): teacher = TeacherSerializer() tags = TagSerializer(many=True) student_count = serializers.SerializerMethodField()…

    Grace Wanjiru4likes3comments

  7. Question

    Python script works when I run it, does nothing in cron. What am I missing?

    Quick one. Practicing Linux for the transition (ETS in 7 months, SkillBridge after that if it gets approved). Wrote a Python script that pings a list of hosts and writes the results to a CSV. Works fine when I run it from my home directory. Put it in crontab -e to run every 5 minutes. Nothing. No CSV, no error, nothing. */5 * * * * python3 pinger.py What I checked: cron is running ( systemctl status cron says…

    Ray Alvarez10likes6comments

  8. Experience

    How I explain loops with appam batter (and why my children remember it in the board exam)

    Fourteen years of teaching Python to higher secondary children in Kochi has taught me one thing: they will forget the definition, but they will never forget the story. So here is the story I use for loops. Other teachers are welcome to steal it. The appam pan Every child in Kerala has watched their amma or ammachi make appam. You have a bowl of batter and an appachatti (the round pan). One ladle of batter, swirl the…

    Anitha Joseph7likes8comments

  9. Question

    Django endpoint does 300+ queries, select_related vs prefetch_related confusion

    Hi, I am intern at a fintech, writing internal API in Django REST Framework. Endpoint /api/transfers/ returns 50 transfers and django-debug-toolbar shows 312 queries xD Models: Transfer has two ForeignKeys to Account (sender, receiver), Account has ForeignKey to Customer , and Transfer has ManyToMany tags . class TransferViewSet(viewsets.ReadOnlyModelViewSet): queryset = Transfer.objects.select_related("sender",…

    Kacper Nowicki13likes9comments

  10. Question

    Pandera, Great Expectations or plain asserts for data validation in a small team?

    Hola! Small data team (3 people), Python, pandas, some dbt, Airflow. We have zero data validation, and last month a supplier changed a column from euros to cents without telling anybody. Our revenue dashboard showed 100x for two days 🙃 Nobody noticed until the CFO was very happy, and then very angry. I want to add validation at the ingestion step. The options I see: pandera : schemas in Python, looks light. Great…

    Núria Puig13likes6comments

  11. Article

    We replaced an LLM feature with a regex and nobody noticed

    This is the regex post I threatened in June. Context: one step of our support pipeline extracts identifiers from inbound emails: order numbers, return authorisation (RMA) codes and carrier tracking numbers. Last year, in the general enthusiasm, this step was moved from a pile of old code to an LLM call: "here is an email, return JSON with any order number, RMA code and tracking number you find". It worked. It demoed…

    Dana Kowalski84likes37comments

  12. Article

    We moved our nightly jobs to the greenest hours of the grid. Here's what it saved (spoiler: less than you'd think, and that's the point)

    I'm a data analyst at a community energy co-op in Bristol. We're small: about 400 member households, a few solar roofs, a share in a wind turbine, and one Linux box in a rack in a shared data centre that runs all our nightly jobs (meter data imports, billing calcs, the dashboards members look at). People in this topic keep asking about carbon-aware scheduling, so here's an honest write-up of doing it for real,…

    Freya Collins41likes17comments

  13. Experience

    Year 10 handed me 28 nearly identical AI essays on how a CPU works. Here's what I do now

    Evening all. Marking on a Sunday again, so you get a post. Last term I set Year 10 (14 and 15 year olds) a short homework: explain the fetch-decode-execute cycle in your own words, 300 words, with an example. I got 28 essays back from a class of 31. At least 22 described the CPU as "the brain of the computer, orchestrating" something or other, and four mentioned a register that isn't on our spec at all. Two ended…

    Rhys Llewellyn26likes9comments

  14. Experience

    Norway became false

    Config had a list of Nordic country codes for a region filter. FI, SE, DK, NO, IS. Service read it with PyYAML. Norway was missing from the filter. countries: - FI - SE - DK - NO - IS PyYAML follows YAML 1.1, where NO , no , off , yes and friends are booleans. Python got ['FI', 'SE', 'DK', False, 'IS'] . Filter compared strings. Norway silently gone. Two hours. Fix: countries: - "FI" - "SE" - "DK" - "NO" - "IS" Also…

    Jussi Laaksonen21likes9comments

  15. Article

    Teu modelo tem 99% de acurácia? Bah, então me mostra a matriz de confusão

    Bah, tchê. Toda semana aparece alguém no LinkedIn com "meu modelo atingiu 99% de acurácia" e um gráfico bonito. E toda semana eu tenho as mesmas três perguntas. Vou deixar aqui pra poder mandar o link 🧉 1. Qual é a proporção das classes? Se 99% das transações não são fraude, um modelo que responde "não é fraude" pra tudo tem 99% de acurácia. E não pega fraude nenhuma. Tu viu? Acurácia sozinha não diz nada quando as…

    Bruna Schmitt6likes7comments

  16. Article

    How I check a strike location with free satellite data, and when I refuse to publish

    A reader asked how we decide whether a claimed strike location holds up. Here's the free toolkit and the actual decision rule. Nothing here needs a paid account. The free sources Sentinel-2 (ESA, optical): 10 m resolution in the visible bands, a new image roughly every 5 days at mid latitudes. Big burn scars, collapsed large buildings, craters in fields. Not cars, not people. Sentinel-1 (radar): sees through clouds…

    Naomi Feld9likes6comments

  17. Article

    Antes de culpar al modelo, mira tus etiquetas

    Lo prometí en el otro post, así que aquí va en castellano (y algo de català, perdón). Teníamos un clasificador de reseñas de clientes con 5 categorías: producto, envío, precio, atención al cliente y "otro". Llevábamos dos meses probando modelos: TF-IDF con regresión logística, un BERT multilingüe afinado y un LLM con few-shot. Los tres se quedaban en 0.78-0.80 de F1. Siempre lo mismo. Sospechoso, ¿no? El experimento…

    Núria Puig7likes7comments

  18. Article

    Scraping county election results on election night without getting blocked (or getting it wrong)

    Primary season means I spend a lot of evenings refreshing county results pages. Here's how our desk does it, after some years and some embarrassing mistakes (mine). 1. Call the county first Seriously. Many counties publish a JSON or CSV feed behind the pretty results page, and many use the same few results vendors, so once you know one feed format you know a lot of them. Ask the elections office what the official…

    Naomi Feld31likes10comments

  19. Article

    Your model didn't get better, your test set leaked (a checklist)

    A ver. Three times this year a model "improved" by a lot, and three times it was leakage. The last one was a fine-tuned classifier that jumped from 0.81 to 0.93 F1, and my manager already had a slide 🙃 This is the checklist I run now before I believe anything. 1. Exact and near duplicates between train and test The 80% of my leakage problems are this. Customer reviews, support tickets, product descriptions: people…

    Núria Puig19likes7comments

  20. Update

    set the dishwasher to start at 3am because the regional…

    set the dishwasher to start at 3am because the regional carbon intensity forecast said 41 gCO2/kWh then vs 212 at 6pm. housemate says i'm in a cult. fair. the cult has a free REST API and i've written a python script that texts me when the wind picks up

    Freya Collins2likes6comments

  21. Article

    How I build evals for an LLM feature (the boring version)

    This topic exists because I kept seeing launches justified with a demo video and a feeling. So here is the first real post: how I evaluate an LLM feature before it ships. Nothing here is novel. That is the point. The feature, for context: classifying inbound support tickets into one of 14 categories and extracting an order ID if there is one. It is currently handled by a gradient-boosted model plus a regex (more on…

    Dana Kowalski33likes14comments

  22. Experience

    A retired banker's first Raspberry Pi: a weather station on my terrace in Chennai

    Dear friends, I retired two years ago after 34 years in the IT department of a public sector bank. I began with punched cards, spent most of my career with COBOL, CICS and DB2, and learned Java in my fifties because the bank said so. My grandson, who is 17, informed me last year that COBOL is "basically dead" and that I should learn Python. I informed him that COBOL processed his grandmother's pension this morning.…

    S. Ramanathan23likes10comments

Get the best of Dynamo Geeks weekly

One email each Monday with the most useful posts. No spam; unsubscribe in one click.