Skip Navigation

Search

Python @programming.dev
Droid @sh.itjust.works

PieFed, a FOSS Feed Aggregator alternative to Lemmy, but faster

Welcome to a new era of interconnected content discussion with PieFed – a link aggregator, a forum, a hub of social interaction and information, built for the fediverse. Our focus is on individual control, safety, and decentralised power.


Like other platforms in the fediverse, we are a self-governed space for social link aggregation and conversation. We operate without the influence of corporate entities – ensuring that your experience is free of advertisements, invasive tracking, or secret algorithms. On our platform, content is grouped into communities, allowing you to engage with topics of interest and disregard the irrelevant ones. We utilise a voting system to highlight the best content.

Python @programming.dev
bitscomplicated @lemmy.world

I am including the full text of the post


Despite not being a pure functional language, a lot of praise that python receives are for features that stem from functional paradigms. Many are second nature to python programmers, but over the years I have seen people miss out on some important features. I gathered a few, along with examples, to give a brief demonstration of the convenience they can bring.

Replace if/else with or

With values that might be None, you can use or instead of if/else to provide a default. I had used this for years with Javascript, without knowing it was also possible in Python.

 python
    
def get_greeting_prefix(user_title: str | None):
    if user_title:
        return user_title
    return ""

  

Above snippet can shortened to this:

 python
    
def get_greeting_prefix(user_title: str | None):
    return user_title or ""

  

Pattern Matching and Unpacking

The overdue arrival of match to python means that so many switch style statements are expresse

Python @programming.dev
Bimo @lemmy.world

Cli Scraper designed to build your own Alibaba Dataset

First thing first, while I started to build this package I've made an error with the word

<scraper>

that I've misspelled in

<scrapper>

I'm not a native english speaker. I'm planning to change the name and correct it. So don't be mad with me about it. Ok now let me introduce my first python package.

aba-cli-scrapper** i'ts a cli tool to easily build a dataset from Alibaba.

look at the repo to know more about this project : https://github.com/poneoneo/Alibaba-CLI-Scraper

I'm excited to share the latest release of my first Python package, aba-cli-scrapper designed to facilitate data extraction from Alibaba. This command-line tool enables users to build a comprehensive dataset containing valuable information on products and suppliers associated . The extracted data can be stored in either a MySQL or SQLite database, with

Python @programming.dev
slyuser @lemmy.ml

Dice Roller with Python using either tkinter or streamlit

www.slyautomation.com Dice Roller with Python

In this tutorial, we’ll walk through the process of creating a simple dice roller application using Python’s Tkinter library. Tkinter is a popular GUI (Graphical User Interface) toolkit for Python that allows us to create windows, dialogs, and other graphical components for our applications. We’ll a...

Dice Roller with Python

the code on the website is javascript here it is, make sure to create dice images for it to work (e.g dice1.png):

 undefined
    
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dice Roller</title>
<style>
    body {
        font-family: Arial, sans-serif;
    }
    #result-frame {
        margin-top: 20px;
    }
</style>
</head>
<body>
<h2>Dice Roller</h2>
<label for="num-dice">Choose Number of Dice:</label><br><br>
<select id="num-dice">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
</select>
<button onclick="rollDice()">Roll</button>
<div id="result-frame"></div>

<script>
function rollDice() {
    var numDice = parseInt(document.getElementById('num-dice').value);
    var resultFrame = document.getElementById('result-fr
  
Python @programming.dev
Martín @lemmy.world

FastAPI keeps generating local index.html*

I deploy a FastAPI service with docker (see my docker-compose.yml and app).

My service directory gets filled with files index.html, index.html.1, index.html.2,... that all contain

They seem to be generated any time the docker healthcheck pings the service.

How can I get rid of these?

PS: I had to put a screenshot, because Lemmy stripped my HTML in the code quote.

Python @programming.dev
𝕨𝕒𝕤𝕒𝕓𝕚 @feddit.de

Has using 'thing = list()' instead of 'thing: list = ' any downsides?

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?

Python @programming.dev
movie @lemmy.dbzer0.com

Europython2023 MS candy

MS giving away expired candy at EP2023 :)

Python @programming.dev
Devos @programming.dev

Datalookup: Deep nested data filtering library

Hi Python enthusiastic! I'm excited to share my latest project! The Datalookup 🔍 library makes it easier to filter and manipulate your data. The module is inspired by the Django Queryset Api and it's lookups.

I'm actively seeking people to join in and help make this library even better! Whether you have ideas for new features, bug fixes, or improvements in documentation, anyone can contribute to Datalookup's development.

Github: https://github.com/pyshare/datalookup

Python @programming.dev
Troy @lemmy.ca

Showcase: an afternoon of hacking a pyside proof of concept frontend for lemmy

Well, it ain't pretty, but it works eh :)

Python @programming.dev
Scrimby @lemmy.fmhy.ml

i've just started and have some questions about program running.

ok, so I've just started to learn python so very sorry for being a absolute dumbell. I'm doing some test stuff and noticed when I build and run my programs, they run yes, but they don't actually do anything. I've made sure to set the right language in sublime editor. perhaps it's something I've done wrong? when the console prints out the first question, i type in a number, but then nothing else happens. it seems to only print the first line and that's it. it's supposed to prompt the "second:" but it does nothing. I would really appreciate your help. thank you.

Python @programming.dev
Jason Novinger @programming.dev

hjwp/pytest-icdiff: better error messages for assert equals in pytest

Once you've installed it, pytest will produce nice colourised diffs for any assert == :

😍

Via https://mastodon.social/@hynek/110479665200902390

Python @programming.dev
InternetPirate @lemmy.fmhy.ml

Optimizing Script to Find Fast Instances

Last month, I developed a script because lemmy.ml had become too slow. Unfortunately, I have the same problem again, but this time there are too many instances to evaluate, causing the script to take an excessively long time to complete. I'm seeking advice on how to enhance the script to simultaneously ping multiple instances. Are there any alternative scripts available that might provide a more efficient solution?

 undefined
    
git clone https://github.com/LemmyNet/lemmy-stats-crawler
cd lemmy-stats-crawler
cargo run -- --json > stats.json

  
 python
    
#!/usr/bin/env python3
import json
import time
import requests
import requests.exceptions

from typing import List, Dict

TIME_BETWEEN_REQUESTS = 5  # 10 * 60 = 10 minutes
TIME_TOTAL = 60  # 8 * 60 * 60 = 8 hours


def get_latency(domain):
    try:
        start = time.time()
        if not domain.startswith(("http://", "https://")):
            domain = "https://" + domain
        requests.get(domain, timeout=3)
        end = time.time()