Python

7643 readers
35 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
351
 
 

cross-posted from: https://lemmy.ml/post/10682032

I've been looking to create a local database of cooking recipes for personal use, but doing it manually is quite tedious, to say the least. It takes maybe 5-ish minutes per recipe to navigate the various websites copy the text, create file, re-format the inevitably flawed text into readable ASCII only, and look over the result for spelling, grammar, and readability errors (one guy who made the recipes was seemingly barely literate, could hardly pass 3rd grade English class).

Are there any utilities you are aware of that would make this easier? Obviously the more automated the better, but automating text-pulling from a website, line sizing, indents, list formatting, and easy headers would be the minimum to be "worth it". Useful features would be automated file creation and naming, savable config presets, unified functionality (I.E. one utility that does everything, rather than a web API, a reformatter, and a file-writer, for example). The recipes tend to be in a certain format (Rich text? not sure) that prevents much of the readability from being retained when copied and pasted manually.

I'm looking for one single utility if at all possible, due to not wanting excessive headaches on my end. I'm running Linux Mint. Thanks for the heads-up.

352
353
 
 

I have this XML

<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.16.1" type="navidrome" serverVersion="0.50.2 (823bef54)" openSubsonic="true"><searchResult3><song id="3b9d81b5def61a60705b9b89611a217f" parent="03693dd7b835740421cc1d6a4da201f3" isDir="false" title="Good Day featuring ScHoolboy Q" album="I Am &gt; I Was" artist="21 Savage" track="11" year="2018" genre="Rap" coverArt="mf-3b9d81b5def61a60705b9b89611a217f_5c1d3668" size="9716623" contentType="audio/mpeg" suffix="mp3" duration="242" bitRate="320" path="21 Savage/I Am &gt; I Was/11 - Good Day featuring ScHoolboy Q.mp3" created="2024-01-08T16:40:53.026754212Z" albumId="03693dd7b835740421cc1d6a4da201f3" artistId="1ae1d36568c651d53f78f427f05e9766" type="music" isVideo="false" bpm="0" comment=""><genres name="Rap"></genres></song></searchResult3></subsonic-response>

Which I got from an API call

I would like to be able to interact with it so I can check the artist and then pull the id

I thought this would be as simple as calling a key on an array (wrong terminology I know. Dict?), how wrong was I?

Having done some searching, I'm in the process of figuring out how xml.etree.ElementTree works. But it feels so overly complicated for what I'm trying to do? Am I going down the wrong path?

354
6
submitted 2 years ago* (last edited 2 years ago) by sabreW4K3@lemmy.tf to c/python@programming.dev
 
 

****FIXED IT! ****

    if "TXXX:FMPS_Rating_Amarok_Score" in tags:
      rating = tags["TXXX:FMPS_Rating_Amarok_Score"]
      print([key for key in rating])
    else:
      print(" ".join(["No rating exists for",mp3_file,"this song"]))

This code snippet prints the key as ['0.66'] That 0.66 is the exact value that I need?

A searching the internet showed me that people often want this the other way round, but no one seems to try to do what I'm doing? Does anyone have any idea on how to do it?

355
 
 

In my file, I have

from mutagen.id3 import ID3
tags = ID3(mp3_file)

Now if I do print(tags.keys())

It informs me that there's a TXXX:FMPS_Rating_Amarok_Score

But when I attempt to print(tags["TXXX:FMPS_Rating_Amarok_Score"])

It says there's a KeyError. What am I doing wrong?

356
47
Python 3.13 gets a JIT (tonybaloney.github.io)
submitted 2 years ago by ylai@lemmy.ml to c/python@programming.dev
357
 
 

cross-posted from: https://beehaw.org/post/10863052

Noob question incoming, thanks in advance for any help with this!

I have a specific use case in which I want to send an automated email or text to myself once a day (the message is different each time--otherwise I would just set an alarm, lol!). I'm running Pop_OS on an old desktop computer. Where I'm stuck is getting an email to successfully send from the command line. I'm looking for easy-to-follow instructions that would help me do that, and none of the articles or videos I've come across thus far have helped.

I'm aware of Twilio and other services that send SMS messages, but I'm looking for something free. Especially since I only need to text one person (myself), and infrequently at that.

Below is my attempt to send an email with the telnet command. Nothing ever came through...

XXXXXXXX@pop-os:~$ telnet localhost smtp
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 pop-os ESMTP Exim 4.95 Ubuntu Sun, 07 Jan 2024 15:12:28 -0500
HELO gmail.com
250 pop-os Hello localhost [::1]
mail from: XXXXXXXX@gmail.com
250 OK
rcpt to: XXXXXXXX@gmail.com
250 Accepted
data
354 Enter message, ending with "." on a line by itself
Subject: Test
Body: Is this working?
.
250 OK id=1rMZW4-0002dj-Uy
quit
358
359
7
Python Rgonomics | Emily Riederer (emilyriederer.netlify.app)
submitted 2 years ago* (last edited 2 years ago) by ericjmorey@programming.dev to c/python@programming.dev
 
 

cross-posted from: https://programming.dev/post/8257343

Emily Riederer Writes:

Switching languages is about switching mindsets - not just syntax. New developments in python data science toolings, like polars and seaborn’s object interface, can capture the ‘feel’ that converts from R/tidyverse love while opening the door to truly pythonic workflows

Just to be clear:

  • This is not a post about why python is better than R so R users should switch all their work to python
  • This is not a post about why R is better than python so R semantics and conventions should be forced into python
  • This is not a post about why python users are better than R users so R users need coddling
  • This is not a post about why R users are better than python users and have superior tastes for their toolkit
  • This is not a post about why these python tools are the only good tools and others are bad tools

The Stack

WIth that preamble out of the way, below are a few recommendations for the most ergonomic tools for getting set up, conducting core data analysis, and communication results.

To preview these recommendations:

Set Up

Analysis

Communication

Miscellaneous

  • Environment Management: pdm
  • Code Quality: ruff

Read Python Rgonomics

360
361
362
363
 
 

I’m not a software developer, but I like to use Python to help speed up some of my office work. One of my regular tasks is to print a stack of ~40 sheets of paper, highlight key information for each entry (about 3 entries per page), and fill out a spreadsheet with that information that then gets loaded into our software.

This is time-consuming, and I’d like to write a program that can scan the OCR-ed PDFs and pull the relevant information into a CSV.

I’m confident I could handle it from there, but I know that PDFs are tricky files to work with. Are there any Python modules that might be a good fit for the approach I’m hoping to take here? Thanks!

364
 
 

cross-posted from: https://discuss.online/post/4110869

Conda (@conda@fosstodon.org) writes:

Conda is moving our social media presence from Twitter/X to Mastodon and LinkedIn at the start of 2024. It's past time to move into spaces that are welcoming and more in line with our community values. Going forward, you can find us at 🐘 @conda@fosstodon.org (https://fosstodon.org/@conda) 🔗 Conda Community on LinkedIn

Read Conda is moving to Mastodon & LinkedIn | conda.org/blog

Conda (Software)

Conda provides package, dependency, and environment management for any language.

Using conda provides a streamlined approach to package management, platform compatibility, environment isolation, and access to an extensive package ecosystem. It is particularly beneficial for data scientists, researchers, and developers working with diverse software requirements across different projects.

Conda Community

The "conda" community is made up of millions of users, packaging maintainers and tool developers. Conda is not a single organization but rather a concerted effort of many different organizations, all devoted to the mission of providing easy access to various types of free software regardless of the operating system or programming language.

We firmly believe that everyone belongs in open-source, and we want to start by thanking you for taking the time to read this page. What follows is a high level summary of all the projects and organizations which make up the conda community with links provided where you can learn more or get involved yourself. The many meanings of "conda"

Traditionally associated with the Anaconda distribution, nowadays the term "conda" refers to more than just a package manager or a software repository. Its many definitions also encompass community packaging efforts like conda-forge and bioconda, as well as new tools developed in the Mamba and conda-incubator organizations. All these efforts show that the conda ecosystem is no longer defined by a single actor and continues to grow and thrive.

Organizations on GitHub include:

Some tools you might be familiar with are conda or conda-build themselves but also community efforts like mamba, boa, setup-miniconda, conda-lock or conda-tree, among many more.

Read more about the conda community.

365
 
 

Just fyi.

366
 
 

cross-posted from: https://programming.dev/post/8025145

2023-12-29 by Novica Nakov:

I notice that Ctrl+Enter for running the code in Python and in R is not the same thing.

Read the whole article

367
368
369
 
 

Hi,

As CSS do not have a color-overlay[^1] filter.

There is some heavy work around:

https://isotropic.co/tool/hex-color-to-css-filter/

that use a combination of CSS filter to target the desired color...

Those online calculators are neat, but I would like an offline version, in case the provided one become inaccessible.

I've downloaded the zip of https://codepen.io/sosuke/pen/Pjoqqp

But it doesn't work locally.. :/

So I would like to know, if someone know one in 🐍 Python ? or how can I make one then ?

Or if someone know another way to have the color-overlay[^1] effect in html\css, I'm all ears !

Thank.

[^1]: To apply like in Photoshop a color on the shape of the image (so not on the parts that have transparency.

370
371
372
 
 

These stubs have only been out in a pypi package for about 2 months so many people do not know about them yet.

373
374
 
 

Via https://mas.to/@mpirnat/111592702753147583

Looks like talks are already live!

375
 
 

I have developed a project in #python to follow #RSS feeds and send an email with daily news. It is more an excuse to practice python, git and design patterns than a real project, but feel free to use it if you find it useful. Suggestions, opinions and feedback are welcome.

https://github.com/xurxia/newswave

view more: ‹ prev next ›