All things Python

nedbat,
@nedbat@hachyderm.io avatar

Are you sure you know how decorators work? This should be no problem! 😈 🤯 🤓

e_nomem,
@e_nomem@hachyderm.io avatar

@nedbat It took me a moment to remember that the execution happens at load but yeah, you can do some pretty bonkers stuff with decorators.

brohrer,
@brohrer@recsys.social avatar
villares, Portuguese
@villares@pynews.com.br avatar
hugovk,
@hugovk@mastodon.social avatar

📣🐍📚 Calling all Python library maintainers!

Python 3.13 is now in beta, with the second of four beta releases out later today!

It's now time to start testing your libraries with 3.13 and report any problems back to CPython so they can be fixed before the big October release. And make any updates you need to upgrade your library; keep an eye out for removals and deprecations.

Here's how to test 3.13 on GitHub Actions:

https://dev.to/hugovk/help-test-python-313-14j1

#Python #Python313 #beta #GitHubActions

hynek,
@hynek@mastodon.social avatar

@hugovk My understanding is they already fixed it months ago. Guessing their release process is painful.

cfbolz,
@cfbolz@mastodon.social avatar

@hynek @hugovk I think it's mainly undermaintained (just like everything else) :-(

Posit,
@Posit@fosstodon.org avatar

posit::conf(2024) virtual tickets are now available!
Join us on August 12-14—from all over the world—to live stream the incredible talks and keynotes that will be taking place in Seattle.

We understand that not everyone will be able to make the trip to Seattle this year, so we’re excited to offer a fully virtual offering for everyone as an alternate option.
REGISTER: https://posit.co/conference/

#posit #rstats #python #pydata #DataScience

Posit,
@Posit@fosstodon.org avatar

And if you’re available on June 6, join the Data Science Hangout where you can ask any questions you may have about posit::conf(2024) directly to the conf committee including Hadley Wickham, Posit’s Chief Scientist. https://posit.co/data-science-hangout/

pytexas,
@pytexas@fosstodon.org avatar

Reminder that the PyTexas Meetup is tonight! Come by and chat, hangout, and hear about a journey building an AI app. We'll get started chatting around 7:30pm CST and move on to the main presentation at 8:00pm.

See y'all there!

https://pytexas.org/meetup/join




desertplains,
@desertplains@mastodon.social avatar

I wonder if there's a more efficient way of implementing decimal to #binary conversion in #python

Without recursion, it's ok, but there will be variable assignments operations, which seems to me as something not so efficient, comparing with recursion...

image/png

desertplains,
@desertplains@mastodon.social avatar

@tshirtman @diazona humm interesting. I hope I'm not abusing from your good will but, would you mind to elaborate a bit more, or even send some article for reference? I got curious with the "arbitrarily large numbers". Tks.

tshirtman,
@tshirtman@mas.to avatar

@desertplains
https://docs.python.org/3/library/stdtypes.html#typesnumeric says "Integers have unlimited precision" which is to mean it can use as much memory as needed to store bigger values (until your operating system refuses to give more memory to your process). it's not like the C int type, for example, which will have minimum and maximum possible values.
@diazona

treyhunner, (edited )
@treyhunner@mastodon.social avatar

New article on Python's many command-line tools 📣

Did you know that #Python 3.12 comes bundled with 50 command-line tools? 😮

An HTTP server, a sqlite prompt, a code profiler, and so much more! ✨

https://pym.dev/cli-tools/

treyhunner,
@treyhunner@mastodon.social avatar

@hugovk Ooh! I missed this new feature!

This one actually seems really handy 💖

$ python3.13 -m random 6
1
$ python3.13 -m random 3.14159
3.0145311549545397
$ python3.13 -m random this is great
is

I will definitely be updating this article before October. 😁

sonicrocketman,
@sonicrocketman@mastodon.social avatar

@treyhunner Congrats on making HN! Very useful stuff. I use http.server and sqlite a lot. Some are new to me though.

villares, Portuguese
@villares@pynews.com.br avatar
cheukting_ho,
@cheukting_ho@fosstodon.org avatar

Hey, do you want to vote in the upcoming @ThePSF elections? Don't forget to affirm your intention to vote (please check your email, including spam). Deadline: June 25th 2024. Not a member yet? Check how you can become a voting member here: https://buff.ly/3X2cLhL #Python

leahawasser,
@leahawasser@fosstodon.org avatar

I wrote an overview of @pyOpenSci s second (and my second) experience at https://www.pyopensci.org/blog/recap-pyos-pyconus-2024.html

we had a great time with a record amount of sprinters, open space attendees AND i gave my first talk! I can't wait for next year!

Jigsaw_You,
@Jigsaw_You@mastodon.nl avatar

NumPy 2.0 is planned to be released on June 16, 2024. 👍

https://numpy.org/devdocs/release/2.0.0-notes.html

flypig,
@flypig@mastodon.social avatar

The #ResearchEngineering and #ToolsPracticesSystems teams from #TheAlanTuringInstitute wrote up about our experiences at #FOSDEM2024 ... we talk about #OpenResearch, #Python, #HPC and #LinuxOnMobile. Happy memories! #FOSDEM

https://medium.com/

pyconau,
@pyconau@mastodon.pycon.org.au avatar

🎤 Ready to take your public speaking skills to the next level? PyCon AU has your back!

Whether you're a Student, Educator, Graduate, or Professional, we want YOU! We're seeking talks from first-time or seasoned speakers, and we have a fantastic mentoring program to help your proposal shine.

Read more about it here: pycon.org.au/program/-and-feedback

webknjaz,
@webknjaz@mastodon.social avatar

One friend of mine wrote a blog post on his @homeassistant setup:

"Home Assistant helps me survive during missile and drone attacks. Here is how." https://denysdovhan.com/home-assistant-config/config/war/

saving lives IRL y'all!

jscholes,
@jscholes@dragonscave.space avatar

Needed to rename a test fixture in a #Python file, and find/replace wasn't up for the job. So I decided to give #VSCode a go:

I started by pressing Ctrl+F2, for "Change All Occurrences". I think that is basically find/replace, and hence didn't do what I wanted.

Instead, I installed the recommended Python extension, and pressed F2 for "Rename Symbol". That claims to have only made one change, and the references to the function are still using the old name.

So, consider me confused. I'm using #pytest, whereby the test fixtures are referenced as function arguments rather than being called directly. Maybe that's what VS Code is struggling with? Either way, I've now spent more time on this than just manually editing the text.

#VisualStudioCode

nedbat,
@nedbat@hachyderm.io avatar

@jscholes Pytest's style of associating fixtures with tests is quirky, and confuses most language tooling.

nedbat,
@nedbat@hachyderm.io avatar

@mdione @jscholes "Change all occurrences" is using language-specific semantics to find uses of a variable. Here is a function called fx, but it's never used:

def fx(): return 17

def other_func(fx): return fx+1

print(other_func(12)) # 13

bbelderbos,
@bbelderbos@fosstodon.org avatar

Ever wondered how to debug a hanging test in #Python?

pip install pytest-timeout
pytest --timeout=N_SECONDS

To dump the whole stack trace you can add --timeout_method=thread as well.

Here is an example:

bbelderbos,
@bbelderbos@fosstodon.org avatar
mitten,
@mitten@social.lol avatar

So I’m trying to write some little static designs with py5 in Thonny, and when I run the program, the sketch window opens but closes immediately, so I can’t really see what I’ve drawn. It only seems to happen when there is no “def draw():” component in the program (so, non-animated programs which only have the “def setup():” part). Is there a setting somewhere to tell Thonny to keep the sketch result open after running?

villares,
@villares@ciberlandia.pt avatar

@InstantArcade @mitten
Cheers Instant Arcade!
Welcome to the py5 community!

villares, (edited )
@villares@ciberlandia.pt avatar

@InstantArcade @mitten Oh, I'm just an enthusiast who uses it everyday, and I feel part of the py5 community and try to contribute to it! The creator an maintainer is Jim, @hx2A, and the official Mastodon account is @py5coding 😊​

levlaz,
@levlaz@hachyderm.io avatar

spent an hour debugging jinja template before realizing I was passing in the list variable but not by name. :facepalm: #python #programming

anderseknert,
@anderseknert@hachyderm.io avatar

@levlaz I spent half an hour the other day debugging an issue where none of the changes I did seemed to make any difference. Turned out that file was in a different directory than the one I was in.

levlaz,
@levlaz@hachyderm.io avatar

@anderseknert I swear this happens to be once a month 😅

Especially with go because Im always opening sub dirs in their own vscode instance because I am too dumb to get go.work to work for me consistently in complex projects.

ronald,
@ronald@ohai.social avatar

I created a #python script to generate a custom #emulationstation collection of all 5-star #retrogaming games present on #steamdeck. this is a great way to have the best games easily at hand, especially when using large collections.

how to do it?

  1. copy the script from https://pastebin.com/rjam3wYp and name it create.py
  2. run it on your steamdeck by running 'python create.py'
  3. start emulationstation, enable custom collections and voila! all the best games now show in a single list!
steamdeckhq,
@steamdeckhq@mastodon.world avatar

@ronald oh this looks so interesting! So this downloads games for you completely and sets it up with ES-DE?

ronald,
@ronald@ohai.social avatar

@steamdeckhq it is more of a specialized tool. What it does is after you are done setting up, have games, scraped metadata etc you can run this to generate a playlist like shown in the screenshot which contains only the 5 star games. Emulation station does not offer this as a filter by itself so this is a way to still get that list without manually having to add all the 5 star games through the UI one by one.

jezdez,
@jezdez@publicidentity.net avatar

Hey Sphinx users, does anyone know how to configure a Sphinx project to not use in inline anchors for subheadlines which start with integers (e.g. versions in release notes/changelogs)? I mean, other than prefixing the subheadline with 'v’ or ‘Release’?

pradyunsg,
@pradyunsg@mastodon.social avatar

@jezdez IIRC, this comes out of docutils and isn't configurable on Sphinx's end AFAIK. You need some alphabetical character and a unique slug to docutils to not fall back to idN. Link below for the source of truth for this behaviour.

https://github.com/docutils/docutils/blob/ff0b419256d6b7bfdd4363dd078c2255701de605/docutils/docutils/nodes.py#L2182

And, the core logic for "let me pick an id" is at https://github.com/docutils/docutils/blob/ff0b419256d6b7bfdd4363dd078c2255701de605/docutils/docutils/nodes.py#L1346 AFAIK. None of the settings are exposed by Sphinx.

treyhunner,
@treyhunner@mastodon.social avatar

For single-line comments, Python uses the octothorpe character (#), also known as pound, number sign, crunch, and of course, the hashtag character

Read the full article: Multiline comments in Python
https://trey.io/a5O8qe

cm_jc,
@cm_jc@sigmoid.social avatar

@treyhunner like this?

treyhunner,
@treyhunner@mastodon.social avatar

@cm_jc yup just like that. Multi-line strings are great as strings.

They're also great as docstrings: https://pym.dev/docstrings/?watch

But I wouldn't use them as an equivalent to "multi-line comments" in another language (unless everyone else on your team reading your code is already bought in on that odd use).

grrrck,
@grrrck@fosstodon.org avatar

I made a little TikTok about my all-time favorite new #Shiny feature: dark mode! ☀️🌙

This one is for Shiny for #Python, but the #RStats version will be dropping soon so follow the @Posit channel to make sure you catch it!
https://www.tiktok.com/t/ZTL7qM1SK/

grrrck,
@grrrck@fosstodon.org avatar

@10leej @Posit what platforms do you use? They’ll post it to YouTube shorts soon

10leej,
@10leej@fosstodon.org avatar

@grrrck @Posit youtube, peertube

pybonacci,
@pybonacci@mastodon.social avatar

I am completely happy using pip, conda/mamba to manage my dependencies and environments.

Lately (and not so lately) I've seen poertry, pixi, hatch, pipenv, pdm, rye, uv,... Of course I feel I'm missing something. What are your thoughts/comments about these tools?

mathsppblog,
@mathsppblog@fosstodon.org avatar

Just used operator.itemgetter to reorder values of a dictionary.

Quite neat snippet of code:

from operator import itemgetter  
d = {"a": 1, "b": 2, "c": 3}  
it = "cab"  
print(itemgetter(*it)(d)) # (3, 1, 2)  

#python

willmcgugan,
@willmcgugan@mastodon.social avatar

@mathsppblog Clever

sethmlarson,
@sethmlarson@fosstodon.org avatar

Want to follow along with Nate Ohlson who's working on adopting hardened compiler options for as a part of Google Summer of Code 2024? They're publishing to Mastodon!

https://fosstodon.org/@nohlson@social.python-gsoc.org

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