Python

7645 readers
18 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
451
 
 

I have seen some people prefer to create a list of strings by using thing = list[str]() instead of thing: list[str] = []. I think it looks kinda weird, but maybe that's just because I have never seen that syntax before. Does that have any downsides?

It is also possible to use this for dicts: thing = dict[str, SomeClass](). Looks equally weird to me. Is that widely used? Would you use it? Would you point it out in a code review?

452
453
 
 

From the docs:


svcs (pronounced services) is a dependency container for Python. It gives you a central place to register factories for types/interfaces and then imperatively acquire instances of those types with automatic cleanup and health checks.

It’s suitable for implementing Inversion of Control using either dependency injection or service location while not requiring global state, decorators, or mangling of function signatures.


Personally I don't know if I will ever need such a tool; I don't really do web framework-y work right now. But I have a ton of respect for Hynek and enjoy his other projects and his blog posts, so if you need something like this I can recommend it on that basis.

454
 
 

C'est l'heure du stream du samedi 📢

- 12H00 : Lunch code,

- 14H00 : Stream 3310.

Un programme simple et efficace pour bien commencer le week-end 😉

Rejoignez moi sur https://www.twitch.tv/formamac 🍎

#stream #streaming #twitch #python #mooc @pythonhub @chevrierfranckjeannic @python

455
 
 

With the textual-web command you can publish any Textual app on the web, making it available to anyone you send the URL to. This works without creating a socket server on your machine, so you won't have to configure firewalls and ports to share your applications.

456
457
 
 

I'm working on a tool that aims to do two things:

  • bootstrap Lemmy communities with content from their "equivalent" subreddit

  • help people migrate away from Reddit, by setting up a bot account on Lemmy that can be later taken over by their legitimate reddit owner. The idea is that the bot account would follow the equivalent lemmy communities and "registration" could be as easy as having the reddit user sending a DM to a bot to authenticate themselves.

I'm wondering how the people here would feel about me trying out this tool by mapping /r/python to !python@programming.dev ? My plan would be to set up a Lemmy instance that could exclusively be the home for the bot accounts, and then I would handpick a few posts every day to get them mirrored here, comments included. I also have in the roadmap to have responses to let users on Reddit to be notified of the conversations/replies received on the Lemmy post.

My view of pros/cons:

Pros:

  • Those who are already on Lemmy but stay on Reddit because of specific, niche communities will be able to ditch Reddit entirely.
  • More content in the instance, which would help mitigate the common "I want to move to Lemmy, but the content is not there" complaints.
  • A clearer path to migration and less time discussing "where to go if we are leaving reddit?"
  • Admins who object to this can simply deferate from the mirror instance(s).

Cons:

  • If abused, Lemmy communities might start looking like they are filled with bots only. Not really my intention, this is why I am not planning to fully automate this, but also not a big issue given that admins can easily protect themselves for instances that spam too much.
  • It's a legal grey area (though there are so many repost bots out there and I don't see how anyone would try to enforce copyright claims) whose support is mostly on the hands of reddit users.
  • If people look at it as a tool to help them migrate, we can win them over. If this feels too forced, they will more likely side with Reddit and refuse to migrate.

Anyway, please let me know your thoughts.

(Also, the code is Python/Django so if anyone is interested in contributing just let me know!)

458
 
 

im creating an application using curses and im using the getch() function to get keyboard input, the problem is, that it is painfully slow, it takes several seconds to detect the pressed key and normally i have to press the key several times so the program actually detects it, there is a way to make getch() respond instantly (or at least at a usable speed)?

459
 
 

Use Python and Bash to automatically regenerate your guest Wi-Fi password and display the QR Code for joining the said network on a Raspberry Pi Pico display.

460
461
 
 

Came across this framework from this week's Pycoder weekly newsletter.

462
463
26
submitted 2 years ago* (last edited 2 years ago) by Crabhands@lemmy.ml to c/python@programming.dev
 
 

What's the best way to teach my kid programming. I don't know how. He's interested. He's done well in school with Scratch. He's expressed interest in Python, owns a Thumby, but never gets too far on his own. Instead of a Winter sport, we're leaning towards a Python class, however there's none in person. How can i help my kid embrace his passion and learn this skill which will help him his whole life.

He's got Mu installed and has perused youtube tutorials, but they dont hold his interest. Any help is appreciated. Edit: He's 10.

464
 
 

In this video, we adapt a clumsy, non-Pythonic API into an easy to use, easy to understand Pythonic one. We use magic methods such as getitem_, len, enter, and _exit to make our objects a context manager and support the len() function and square bracket indexing. And in the end, we turn what once was ugly, difficult to maintain code into something that other developers would actually want to use.

465
32
Litestar 2.0 Released (blog.litestar.dev)
submitted 2 years ago* (last edited 2 years ago) by Andy@programming.dev to c/python@programming.dev
 
 

Litestar is a powerful, flexible yet opinionated ASGI framework, focused on building APIs, and offers high-performance data validation and parsing, dependency injection, first-class ORM integration, authorization primitives, and much more that's needed to get applications up and running.

https://github.com/litestar-org/litestar/


I am not personally involved in the project, I just like following its development.


I know Medium is annoying, sorry. The content is also copied on Reddit... where you can enjoy such comments as

Why would they waste their time trying to promote to the few people on Lemmy?

😢

466
 
 

I am at a high-beginner/low-intermediate level in Python, and one thing that drives me nuts is how poorly I am able to read the Python official documentation and grok how to use the described code.

What's the secret? Are there any guides/videos/books that can help my understand how to approach reading it? Or, is it just one of those things that I need to just keep coming back to while coding, and eventually I will get the hang of it?

467
468
469
 
 

@beeware is doing some pretty cool stuff for #python @python
So cool to see my python program running on my #android phone.

470
 
 

Concurrency has a lot to do with sharing one resource, and Python has dedicated tools to deal with that depending on the resource you must share.

If you have to share one CPU while waiting on the network, then the specialized tools for this are asyncio, twisted, trio, gevent, etc.

Asyncio is the current standard to do this, but tornado, gevent and twisted solved this problem more than a decade ago. While trio and curio are showing us what the future could look like

But chances are, you should use none of them.

Discussion on Hacker News

471
472
 
 

Microsoft is bringing popular programming language Python to Excel. A public preview of the feature is available today, allowing Excel users to manipulate and analyze data from Python.

You won’t need to install any additional software or set up an add-on to access the functionality, as Python integration in Excel will be part of Excel’s built-in connectors and Power Query. Microsoft is also adding a new PY function that allows Python data to be exposed within the grid of an Excel spreadsheet. Through a partnership with Anaconda, an enterprise Python repository, popular Python libraries like pandas, statsmodels, and Matplotlib will be available in Excel.

473
474
475
view more: ‹ prev next ›