publicvoit, to programming
@publicvoit@graz.social avatar

What happens, when you join two paths in a language when the second one is an absolute one?

join("foo", "/bar")
returns "foo/bar" or "/bar"?

The wonderful @meisterluk wrote a great article about that you might want to read: https://lukas-prokop.at/articles/2024-05-03-filepath-join-behavior

I can not tell what version I'd actually prefer. There are situations where both versions would be "proper".

#C++

mblayman, to python
@mblayman@mastodon.social avatar

🐍 On this Building SaaS with and , I started a new feature to add a PDF report bundle to my homeschool app. This will be useful when a user completes their school year and needs records of all the year's activities. https://www.youtube.com/watch?v=cM2sA1AP3fM

bbelderbos, to python
@bbelderbos@fosstodon.org avatar

Use removesuffix for safe suffix removal in >= 3.9 (there's also removeprefix) 🐍

Benefits 💡

• It ensures the suffix is present before attempting to remove it.

• It explicitly specifies which suffix to remove, thus avoiding ambiguity.

• Better named methods 😍

nobodyinperson, to python
@nobodyinperson@fosstodon.org avatar

I think I have finally™️ (for the third or so time) found myself a solution for :python: development on :nixos: that allows me to just work with et. al. as on other distros.

The solution is to pre-build an FHSUserEnv in your configuration.nix, e.g. like this¹.

When starting Python dev work, I now execute fhs (it's fast!), or directly fhs -c 'poetry shell' and everything works as expected, including wheels etc.

¹https://gitlab.com/nobodyinperson/nixconfig/-/blob/main/fhs.nix?ref_type=heads

cc @publicvoit

paul, to python
@paul@fedi.nlpagan.net avatar

I started coding my book management program on April 5th, so last month.
Change log already has 16 updates.

minioctt, to gaming Italian

Ieri ho effettivamente provato un po’ il Switch dal 3DS in portatilità, alla fine, e… che dire. 7/10. Certo, ogni tanto la connessione fa scherzetti e il gioco inizia a freezare per un po’, ma nel complesso si gioca con un lag accettabile e un video senza strani artefatti, veramente apprezzabile. Devo però capire perché in certi rari momenti il client crasha completamente invece di riuscire a ristabilire la connessione, e temo anche la batteria del 3DS si appiattisca troppo velocemente con questa … ma vabbè, a sistema consolidato potrei anche usare il telefono. 🐚

Visto che voglio provare meglio il setup, mi sono portata avanti e ho fatto un programmino per che legge direttamente gli input del gamepad virtuale e li invia alla ; quindi, eliminando quegli altri due programmi necessari, sostituendoli con uno solo. La finestra inoltre visualizza il video da dispositivi di cattura standard, e quando lo implementerò riprodurrà anche audio, quindi sostituirà anche il riproduttore multimediale… per ora non ho ancora la scheda di cattura HDMI, quindi devo ancora usare SysDVR, ma almeno mi mostra il video della webcam (che mi serve per navigare nei menu di sistema, il DVR non lo trasmette), quindi già scendo da 4 app e finestre a solo 2. ✨️

https://octospacc.altervista.org/wp-content/uploads/2024/05/image-1.pngImplementare la lettura degli input del controller, e l’invio al demone sys-botbase tramite socket TCP, è stato un po’ intricato, ma alla fine il codice è venuto pulito, i tasti rimappabili tramite file config, e sorprendentemente sembra tutto ben funzionante dal primo momento… Nel senso, i comandi sembrano rispondere bene senza particolari accorgimenti; anzi, anche meglio di NXController, perché io invio direttamente i valori degli stick analogici alla console, mentre lui deve leggere valori rimappati alla tastiera e quindi tutti digitali. In effetti non ci avevo pensato quando mi era venuta questa , ma effettivamente ho migliorato la mia anche in questo modo, ora ho input più precisi. 🤏️Volevo inizialmente usare Ren’Py, ma ho subito scoperto che non include funzioni per accedere ai dispositivi video, né tantomeno ha la classe camera nella sua implementazione di , quindi… ho usato semplicemente Pygame, e in poche righe di codice funziona già tanta roba, anche se la UI non è delle migliori. Dovrò investigare se davvero non ci sarebbe stato verso di usare l’altro engine oppure si, perché potrebbe tornare utile in futuro. Ancora versione molto WIP, diversi bug da sistemare, ma almeno l’ho già caricata … poi creerò anche dei pacchetti standalone (che includono già e le librerie) per Windows e Linux. L’ho chiamato comunque, meglio evitare qualunque pretesto di violazione del trademark di per il nome … 🚨️

Ma, ovviamente, non era un mio secondario se non saltava fuori un inaspettato mentre programmavo e testavo… il codice che controlla la versione dell’OS di pygame.camera è rotto su Windows Server, e quindi l’inizializzazione fallisce… evviva. L’ho identificato e sistemato subito, ho anche inviato la PR , quindi non è stato un vero problema, però… che cazzo, non è possibile che tutto quello che finisce in mano a me si rompe… trovare bug in librerie così utilizzate e famose senza fare nulla di particolare non è roba da tutti, eppure ormai siamo ad uno a settimana, e chissà cosa mi riserva il futuro. 💣️

https://octospacc.altervista.org/2024/05/04/framionx/

treyhunner, to python
@treyhunner@mastodon.social avatar

The REPL will automatically print any result that isn't None.

Read more 👉 https://trey.io/ibXciv

cdp1337, to homelab
@cdp1337@social.veraciousnetwork.com avatar

So if you are looking for a network diagnostic utility (command line), something you can run on a laptop when doing common troubleshooting for misbehaving networks, what are some features you'd like to have?

Thus far I'm thinking

  • IP
  • link speed
  • neighbor data via LLDP (to know what port a given outlet is plugged into)
  • gateway
  • DNS info
  • "is google reachable"
yantor3d, to python
@yantor3d@mograph.social avatar

A dutiful dev writes a test for both sides of the if/else for 100% coverage.

A lazy dev re-writes the if/else as a ternary operator for 100% coverage.

isagalaev, to python
@isagalaev@mastodon.social avatar

My biggest gripe about docs and modern search engines: the query "python f-string" finds a lot of trash instead of what I always look for: a reference. https://docs.python.org/3/library/string.html#formatstrings

ipv6rs, to python
@ipv6rs@mastodon.social avatar

Shoutout to "python -m http.server"!

satya, to python
@satya@mas.to avatar

TIL, after 22 years of using Python, that str.startswith can take a tuple of prefixes.

ambv, to python
@ambv@mastodon.social avatar

The core․py podcast wasn't dead, it was just sleeping! Pablo Galindo and I return to talk about the upcoming new REPL in 3.13 ♒️

Join us for our signature professional takes just in time for Python 3.13 beta 1 and 🛜

https://podcasters.spotify.com/pod/show/corepy/episodes/Episode-10-The-Interactive-REPL-e2j788i/a-ab7uiak

ThePSF, to python
@ThePSF@fosstodon.org avatar

With less than two weeks until @pycon, we’re excited to share our Annual Impact Report for 2023 🤩 Check it out, share, and come tell us what you think at the PSF Booth at !
https://www.python.org/psf/annual-report/2023/

carlton, to random
@carlton@fosstodon.org avatar

The latest version of added project-local lifecycle hooks, so you can add a postactivate to Git, and so on.

Update from the front: They're awesome! 🤩

I've taken to leaving myself little motd type messages...

> Your working on django-filter. Enjoy! 🍰

I'm loving it 🥰

treyhunner, to python
@treyhunner@mastodon.social avatar

If you'd like to serve up a different directory besides the current one (which is the default) you can provide a -d argument specifying the directory to serve.

Read more 👉 https://trey.io/IiyLcg

bbelderbos, to python
@bbelderbos@fosstodon.org avatar

Managing environment variables in , python-dotenv or -decouple?

When I need to:

from distutils.util import strtobool
DEBUG = bool(strtobool(os.getenv('DEBUG', 'True')))

...to ensure correct types, I opt out of python-dotenv. Python-decouple (or Pydantic) it is for me :)

slott56, to python
@slott56@fosstodon.org avatar

Hadn't thought this before. But.

>>> a = 2  
>>> a′ = a + 1  
 File "<stdin>", line 1  
 a′ = a + 1  
 ^  
SyntaxError: invalid character '′' (U+2032)  

The Unicode Prime (and Double Prime) should be valid parts of an identifier. Maybe a few others that are widely-used.

>>> a² = a ** 2  
 File "<stdin>", line 1  
 a² = a ** 2  
 ^  
SyntaxError: invalid character '²' (U+00B2)  
gnulinux, to python German
@gnulinux@social.anoxinon.de avatar

Python: Tastatureingaben erfassen

Eine Schleife durch einen Tastendruck zu unterbrechen, ist in Python gar nicht so einfach. Doch die KI weiss, wie es geht.

https://gnulinux.ch/python-tastatureingaben-erfassen

davidism, to python
@davidism@mas.to avatar

Anyone know of a library for getting docstrings for attributes like Sphinx does, where it can find the triple-quote string after an attribute by inspecting the AST? I would like to use those docs, but I don't want to write the AST inspector myself 😅

carapace, to python
@carapace@mastodon.social avatar

(In )

x = 1
while True:
print(bin(x)[2:])
x = x ^ (x << 1)

1
11
101
1111
10001
110011
1010101
11111111
100000001
1100000011
10100000101
111100001111
1000100010001
11001100110011
101010101010101
1111111111111111
10000000000000001
110000000000000011
1010000000000000101
11110000000000001111
100010000000000010001
1100110000000000110011
10101010000000001010101
111111110000000011111111
1000000010000000100000001
11000000110000001100000011
...

https://en.wikipedia.org/wiki/Sierpi%C5%84ski_triangle

royal, to python
@royal@theres.life avatar

I think in PowerShell and can manage in Python. I want to learn Rust to the degree I can write in it directly, rather than prototyping in PowerShell and then converting.

A lot of what I do is data manipulation and analysis. (Take several CSV files as input, and output new CSV files that answer business questions based on the inputs.) I'm seriously impressed with Rust's performance here.

If you've made this transition, advice on where to begin?

pixelate, to accessibility
@pixelate@tweesecake.social avatar

Please boost for reach if this kind of stuff interests you. Will post more on this later.

Once upon a time, there was a cool emulator frontend called Retroarch. This emulator wasn't accessible until I and a few other gamers went to them and asked about adding accessibility. An amazing person known as BarryR made it happen. Now, if you turn on accessibility mode in settings, or pass the "--accessibility" (or something like that) flag on the command line, you get spoken menus, including the emulator's pause menu, good for saving states and such. Then, using PIL and other image processing Python utilities, running a server and hooking into Retroarch, the script allowed players to move around the map, battle, talk to NPC's, ETC. The only problem was, no one wanted to test it. The blind gaming community pretty much spoke, saying that we want new games. We want cool new, easy accessibility. So that's what we have no, follow the beacon or get sighted help in the case of diablo and such. It's sad, but meh. It's what we wanted I guess. No Zelda for us. So, this is about as far as he got:

To expand on what devinprater was saying: I am working on an accessibility pack/service for Final Fantasy 1 for the NES (this was what was shown in the latest RetroArch update). The idea is similar to how Pokemon Crystal access works, but it's using the RetroArch AI Service interface to do so.
Right now, the FF1 access service is mostly done, but I need more testers to try it out and give me feedback on how it's working. Right now, you can get up to the point where you get the ship, but there's no code to deal with how the ship moves, so that still needs to be done. Likewise with the airship later on.
The service works the latest version of RetroArch, on linux and mac, but not windows. This is due to how nvda reads out the text and until the next major update to nvda (which will have a feature to fix this), it'll have to wait. If you have those, I (or maybe devinprater) can help you set it up on mac/linux to test out. The package itself is available at: https://ztranslate.net/download/ff1_pac … zip?owner=

#accessibility #finalFantasy #RetroArch #blind #emulator #emulation #Python #ai #ML #MachineLearning

mariatta, to python
@mariatta@fosstodon.org avatar

You can do this with f-strings expressions and the debug mode:

>>> some_value = None
>>> f"{some_value is None=}"
'some_value is None=True'

>>> some_number = 100
>>> f"{some_number > 50=}"
'some_number > 50=True'

Learn more about f-strings and debugging with it by watching my short talk here: https://youtu.be/SNA2O0NQl_Q

cs, to random
@cs@mastodon.sdf.org avatar

I told #copilot I wanted an ASCII art of a volvo driving in Texas. It first told me I had to sign in to create images. I told it I wasn't asking for an image, but ASCII art. It then complied with something that doesn't look like a Volvo, and definitely has nothing that even stereotypically looks Texan.


/|||`.__
( _ _ \
=`-(
)--(_)-'

cs,
@cs@mastodon.sdf.org avatar

For those who might care or just be curious. I was able in a few minutes to get #Codeium to create a #python script to do this. It made a couple of missteps, but I was able to guide it in the right direction and end up with this #ascii art.

http://cseiler.freeshell.org/volvo_ascii.txt (raw text looks better white on black, but browser settings may vary)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • anitta
  • Durango
  • magazineikmin
  • hgfsjryuu7
  • InstantRegret
  • everett
  • rosin
  • Youngstown
  • slotface
  • ngwrru68w68
  • mdbf
  • cisconetworking
  • kavyap
  • DreamBathrooms
  • modclub
  • PowerRangers
  • thenastyranch
  • ethstaker
  • khanakhh
  • tacticalgear
  • osvaldo12
  • tester
  • normalnudes
  • vwfavf
  • cubers
  • GTA5RPClips
  • Leos
  • provamag3
  • All magazines