Python

6288 readers
8 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 1 year ago
MODERATORS
401
6
Flip it around (self.python)
submitted 1 year ago by stOneskull to c/python
 
 

A friend of mine told me once: make dumb algorithms and smart data. This has stuck with me, and I’ve often been annoyed at the annoying annoyance of making the data.

As an amateur, hobbyist, novice programmer, I want to try things. Right now, I want to make a game. Just a simple little game where you travel through the ‘procedural generated’ dungeons and fight monsters. The algorithms can be pretty easy..

here = Room() world.append(here) here.describe()

You could basically make the Room class do everything.

The shitty part is where you think, ‘Ok, what rooms can there be? What monsters do we fight?’

Then it’s like ‘oh, far out, so cool, data entry..’

Data entry work gets you minimum wage. It’s like a sweeping job or working on a conveyor belt in a factory. Compare that to a programmer wage. It’s a big gulf between. And then you waste your time typing all that garbage in. Your precious time.

Get the robot to make your data! The algorithms are easy for you. You don’t need to type all that data in. It’s so much easier to prompt: ‘make me a python dictionary of 23 unique monsters as keys, with values being another dictionary, with keys this and that, and this and that’ and get what you want back than trying to get it to write algorithms for you. It works so much better this way. Flip it around.

You can always go and edit the data. Tweak it how you like, especially the descriptions. And this is going to be easier and more pleasurable than editing and tweaking the shitty code you try to get it to write. Data is easy for these LLMs. It’s like they were born for it. Make them your data slave. You don’t even have to give them minimum wage.

402
28
submitted 1 year ago by jim to c/python
403
404
405
406
407
 
 

Works with Postgresql, MySql, and SQLite natively.

Extends confirmed support for DuckDB, ClickHouse, BigQuery, and Snowflake via the vdsql plugin.

408
409
19
TOML in Python (til.simonwillison.net)
submitted 1 year ago by sisyphean to c/python
410
7
submitted 1 year ago* (last edited 1 year ago) by Hammerheart to c/python
 
 

I am trying to create a playlist with spotify and the spotipy library in python. However, I keep getting a "No token provided" error when making my API request. However, if I use the same token with a curl request, it works! Can someone please help. This is my code:

auth_manager = SpotifyOAuth(client_id=CLIENT,
                            client_secret=SECRET,
                            redirect_uri="http://example.com/",
                            scope=SCOPE,
                            username=spotify_display_name
                            )
token = auth_manager.get_access_token(
    as_dict=False,
    check_cache=True
)

sp = spotipy.Spotify(auth_manager=auth_manager,
                     auth=token
                     )
user_dict = sp.current_user()
user_id = user_dict["id"]
print(f"Welcome, {user_dict['display_name']}")


# SEARCH
# QUERY FORMAT: "track: track-name year: YYYY"

spotify_search_endpoint = "https://api.spotify.com/v1/search/"
test_query = "track:Hangin'+Tough year:1989"

search_parameters = {
    "q": format_query(test_query),
    "type": "track"
}

results = sp.search(q=search_parameters["q"])
print(results)

output:

{'tracks': {'href': 'https://api.spotify.com/v1/search?query=track%3AHangin%27%2BTough%2520year%3A1989&type=track&offset=0&limit=10', 'items': [], 'limit': 10, 'next': None, 'offset': 0, 'previous': None, 'total': 0}}
{
"error": {
"status": 401,
"message": "No token provided"
}
}

This is really frustrating! The authentication is working, otherwise the token wouldn't have been valid for the curl request. I must be doing something wrong with spotipy.

411
 
 

Shamelessly cross-posting this ...

412
413
 
 

Sometimes unused class or function manages to slip into code base. Static code checkers like ruff, flake8 does not have rules for detecting such globally unused code.

I tried using vulture, but it has too many false positives to have it as part of CI/CD pipeline.

I have tried to implement my own, more reliable check for global deadcode detection.

Please let me know what you think about it.

414
415
416
 
 

Pydantic, Inc. is seeking feedback on their development roadmap. Features currently proposed:

  • Python Analytics/Observability — a logging and metrics platform with tight Python and Pydantic integration, designed to make the data flowing through your application more readily usable for both engineering and business analytics.
  • Data Gateway for object stores — Add validation, transformation and cataloguing in front of object stores like S3, with a schema defined in Pydantic models then validated by our Rust service.
  • Data Gateway for data warehouses — the same service as above, but integrated with your existing data warehouse.
  • Schema Catalog — for many, Pydantic already holds the highest fidelity representation of their data schemas. Our Schema Catalog will take this to the next level, serving as an organization-wide single source of truth for those schemas, tracking their changes, and integrating with our other tools and your wider platform.
  • Dashboards and UI powered by Pydantic models — a managed platform to deploy and control dashboards, auxiliary apps and internal tools where everything from UI components (like forms and tables) to database schema would be defined in Python using Pydantic models.
417
 
 

@python foundation announced that they've hired a new developer in residence, as part of a year-long security enhancement initiative to make the #Python ecosystem more secure. @openssf 's Alpha Omega is proud to sponsor this role.

418
10
Data analysis with SQLite and Python (sqlite-tutorial-pycon-2023.readthedocs.io)
submitted 1 year ago by learnbyexample to c/python
 
 

This is text version of PyCon 2023 tutorial. Video can be found at: https://www.youtube.com/watch?v=5TdIxxBPUSI

419
4
submitted 1 year ago by jnovinger to c/python
 
 

Having spent time with Kotlin's by lazy, I really like the lazy item.

Most of the others I don't have strong opinions about, yet.

420
 
 

Hey all! I Just submitted c/Python to sub.rehab, which is currently on the front page of HN. It seems there is some manual submission review in place, but we seem to meet the minimum requirements for submission so hopefully we'll show up in the search results soon.

421
 
 

textual is about the neatest Python library I've come across lately, allowing you to quickly build TUIs (textual user interfaces).

textual provides the building blocks to build beautiful interfaces fast, that work on systems with low resources, across platform, and even run across remote SSH sessions.

They've got a nice tutorial as well as a growing Discord community. Be sure to at least check out their demo and examples.

422
 
 

It's Talk Tuesday time over in @python #community . Head over and submit your favorite #python related conference talk and let us know what made it great.

Fair warning, it's going to be hard to beat mine, my first @raymondh talk, https://pyvideo.org/pycon-us-2013/transforming-code-into-beautiful-idiomatic-pytho.html! 😛

423
10
Talk Tuesday (self.python)
submitted 1 year ago by jnovinger to c/python
 
 

Link your favorite Python conference talk and give everyone else a chance to be blown away like you were the first time you heard it!

Please also include some description of what you liked about the talk. Also, the only requirement is that it is at least tangentially related to Python, so talks about developing in Python, developing CPython, general programming techniques that also apply to Python, some Python library, or even the community are all fair game.

Also, feel free to submit more than one talk, but please include only one talk per top-level comment so that we can have a place to discuss each one.

424
 
 

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

From the article:

symbex inspect_hash | llm --system 'explain succinctly'

Output:

This function calculates the hash of a database file efficiently by reading the file in blocks and updating the hash object using SHA256 algorithm from the hashlib module. The resulting hash value is returned as a hexadecimal string.
425
 
 

Hello everyone!

I'm here to share a project I've been working on, Plemmy. Plemmy is a Python package for accessing the Lemmy API, specifically through LemmyHttp.

Feel free to offer advice and contribute!

Edit: version 0.2.0 released, all LemmyHttp operations are supported! (Most methods still need testing)

view more: ‹ prev next ›