676
8
677
15

Originally saw this in a post by the author on Mastodon: https://fosstodon.org/@rednafi/110644868109506095

678
10

See Seth's earlier post Announcing that he was taking up the place: https://sethmlarson.dev/security-developer-in-residence

679
18

One of the coolest projects I've seen: a lisp that is embedded into Python. Hy compiles to Python AST so it's (almost) fully interoperable with Python (some notes about it here).

680
20
Python 2 in Python 3! (programming.dev)
submitted 3 years ago* (last edited 3 years ago) by qwop@programming.dev to c/python@programming.dev

A post about how this community's banner used the python 2 print syntax - print "Hello World" - made me question, can we print a hello world message in Python 3 without using parentheses?

It turned out to be sort of a fun challenge, I've found 3 different approaches that work. I'd be interested to see what you come up with! (it seems I can't put spoilers in Lemmy, so I won't share my solutions yet in case y'all want to have a go).

Edit: Posted my solutions in the comments

681
20
submitted 3 years ago* (last edited 3 years ago) by great_meh@discuss.tchncs.de to c/python@programming.dev
Python 3.11.3 (main, Jun  5 2023, 09:32:32) [GCC 13.1.1 20230429] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print "Hello World"
  File "<stdin>", line 1
    print "Hello World"
    ^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

I hope this doesnt reflect on the Quality of this community 🤡

682
13

Also will provide automated posts in it for new releases etc.

683
7

The Pure Python web framework survey is here - https://metaperl.github.io/pure-python-web-development/intro.html

Recent Updates

684
21
685
7

Austin is a Python frame stack sampler for CPython written in pure C. Samples are collected by reading the CPython interpreter virtual memory space to retrieve information about the currently running threads along with the stack of the frames that are being executed. Hence, one can use Austin to easily make powerful statistical profilers that have minimal impact on the target application and that don't require any instrumentation.

686
6
Flip it around (programming.dev)

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.

687
28
688
14
689
6
690
10
691
5
692
5
submitted 3 years ago* (last edited 3 years ago) by jnovinger@programming.dev to c/python@programming.dev

Works with Postgresql, MySql, and SQLite natively.

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

693
19
694
19
TOML in Python (til.simonwillison.net)
695
12

Want to get £628.47 worth of Python training courses by Mammoth Interactive for £19.89 whilst also raising money for the Childrens Miracle Network?

Be sure to check out this latest software bundle by Humble Bundle!

696
5
submitted 3 years ago* (last edited 3 years ago) by Hammerheart@programming.dev to c/python@programming.dev

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.

697
50

Shamelessly cross-posting this ...

698
19
699
22

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.

700
13
submitted 3 years ago* (last edited 3 years ago) by jnovinger@programming.dev to c/python@programming.dev
view more: ‹ prev next ›

Python

8022 readers
2 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 3 years ago
MODERATORS