python

Back Open Paginator
09.12.2025 05:00
AdamOnza (@AdamOnza@mastodon.online)

Using my Leif editor to do actual editing.🕶️
Old habits die hard. My 1st impulse is to use Notepad, but I made Leif into a class and module that I can load in #Python Idle. So even though I haven't implemented search and replace, I can just launch editor windows from IDLE, and modify their contents with code! Which is as good, & more powerful. Maybe IDLE could use a module that allows users to access and modify text like that, if it doesn't exist already. Or it could be dangerous.




Show Original Post


09.12.2025 04:55
lobsters (@lobsters@mastodon.social)

Metacode: The new standard for machine-readable comments for Python lobste.rs/s/yp9mou
github.com/pomponchik/metacode




Show Original Post


09.12.2025 04:36
villares (@villares@pynews.com.br)

Code at: github.com/villares/sketch-a-d
More sketch-a-day: abav.lugaralgum.com/sketch-a-d
If you like this, support my work:
paypal.com/donate/?hosted_butt
liberapay.com/Villares
wise.com/pay/me/alexandrev562 #Processing #Python #py5 #CreativeCoding





Show Original Post


09.12.2025 03:01
TheRealPomax (@TheRealPomax@mastodon.social)

Let's see if AI can explain how this PERL 4 code works, and covert it to (widely available) or (less widely available, but often much faster).

github.com/pomax/tex2utf




Show Original Post


09.12.2025 02:39
CuratedHackerNews (@CuratedHackerNews@mastodon.social)

Latency Profiling in Python: From Code Bottlenecks to Observability

quant.engineering/latency-prof




Show Original Post


09.12.2025 01:41
ubuntu_touch (@ubuntu_touch@mstdn.social)

Diseñar una tarjeta de presentación
- Oferta de curso de Python

Quieres aprender a programar en Python ?"
Algunas semanas y estarás en el camino correcto

#Python #CostaRica Costa Rica Guanacaste Liberia San Jose





Show Original Post


09.12.2025 01:06
jamesthebard (@jamesthebard@social.linux.pizza)

Content warning:Advent of Code Solution - Day 8 (Python)


This took just a smidge longer than the Rust solve, but still not too horrible coming in at around 1.5 to 2 seconds. Getting all of the potential coordinate combinations along with their distances sorted made everything so much easier.

Solution: git.jamesthebard.net/jweatherl

#aoc #aoc2025 #adventofcode #adventofcode2025 #programming #python




Show Original Post


09.12.2025 00:56
darbales (@darbales@rollenspiel.social)

#python Lerncode des Tages:
import numpy
import numpy as np
import random
print(np.random.random(10))




Show Original Post


09.12.2025 00:17
fcodvpt (@fcodvpt@framapiaf.org)

La présentation d'Ava Katushka, « What you need to know about computer memory as a programmer explained by Lilliputians », est très pédagogue, joyeuse et belle. Je la recommande

Ava Katushka's presentation is very educational, joyful and beautiful. I recommend it.

youtube.com/watch?v=IUPSnSCJbP

#pyladiescon #python




Show Original Post


08.12.2025 23:43
winslowjosiah (@winslowjosiah@hachyderm.io)

📝 Advent of Code 2025 Day 8: Playground

josiah.win/a/2025/8

I had never heard of a "union-find" data structure before, but it ends up making Parts 1 and 2 almost trivial today. Much better what I did to solve it myself. 😅

#python #AdventOfCode2025 #programming #coding




Show Original Post


08.12.2025 23:20
Tipa (@Tipa@gamepad.club)

Advent of Code 2025: The Playground

This is the one where I am forced to drop Picotron and fall back to Python.

westkarana.blog/2025/12/08/adv

#AdventOfCode #Python #Lua #Picotron




Show Original Post


08.12.2025 23:16
oots (@oots@infosec.exchange)

Today I committed and pushed my code implementing "for" loops for my pet #programminglanguage, #rocket.

So, if an object has an `__iter__` method and the object returned by that has a `__next__` method, you can now write:
```
for x in my_object:
...
```

So far I haven't implemented the `else` branch (that's supported by #Python), because I'm not sure how useful/common that actually is.
Also, so far the syntax is limited to a single variable, unpacking something (e.g. `for i, x in enumerate(my_object)`) is not yet supported.

I feel like half of the effort/code went into handling the new variable `x`. It can optionally be declared with a type (e.g. `for x: int64 in my_object`), in which case it will be treated as a *new* variable (that exists only inside the loop). If you *omit* the type, it imitates the behaviour of an assignment statement (i.e. `x = ...`).
In that case, it either
- uses an existing variable or
- creates a new variable or
- throws a `TypeError`.

While writing test-cases I also discovered a bug elsewhere in my code:
Two of my new test cases (for the for loops) check that the for loop can work with `__iter__` and `__next__` methods of a different type. E.g. if you have a type `A`, type `B` inherits from type `A`, and the `__iter__` method was declared with a parameter of type `A` (rather than `B`), you should still be able to write `for x in B(): ...`, because the object of `B` is also an instance of `A`, so you should be able to call `__iter__` with a parameter of type `B`, too.
(As another example, `__iter__()` could have an optional, second parameter, and it should still work in a for loop.)

Anyway. While writing these test cases, I discovered the bug that (currently) you cannot actually declare a variable with a fixed type if that type is a `protocol`. The reason is that so far my code assumed that every type has a *default value*. (E.g.: the default value of ints is 0, the default value of boolean is `False`.) However, that doesn't make sense for *protocols*, since
a) there's no guarantee there is a type implementing the protocol when the variable is created (there's not even a guarantee there will ever be a type implementing the protocol) and
b) even if there where many types implementing the protocol, it wouldn't make sense to arbitrarily choose one of them and initialise the variable with the default value of that type. That would be completely random guesswork.

I guess I'll have to drop the assumption that every type has a default value, but...
That was a nice assumption, because it made life *so much* easier.
Consider for example creating an array of type `T`. If `T` has a default value, there's no issue, you just allocate the array and initialise all the items in the array with the default value, then let the programmer do with it as (s)he pleases. There is no risk the programmer might use uninitialised memory. If `T` does *not* have a default value... You'd have to make sure that every item in the array gets initialised *by the programmer*.
But what if the programmer wants to create an `ArrayList[T]`? In that case the programmer *naturally* wants to over-allocate a bit, e.g. create an array (backing the list) with space for 16 (or so) elements, even when the list doesn't actually contain any items, yet. Again, if `T` has a default value, you can handle it safely, just initialise all the array items immediately after allocation. If `T` doesn't have a default value, you can't really initialise the array items when allocating the array, you have to rely on the programmer to do so. But then you want to make sure that every no array item is *read* before it has been initialised *by the programmer*, *somehow*. (I don't really have an idea how.)

#programming #programminglanguages #RocketLang




Show Original Post


1 ...852 853 854 855 856 857 858 859 860 861 862 ...1571
UP