Python

"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python cypherpunks 5d ago 100%
Rust macro to inline Python(-ish) code
https://crates.io/crates/inline-python

cross-posted from: https://lemmy.ml/post/21461907 > So, this uses a macro, but if you're thinking anything is possible with a macro, it's actually not in Rust. The input does still need to parse as valid Rust tokens. > > Which means the authors asked themselves at some point: Is the Rust syntax a superset of the Python syntax? > And well, it's not. In particular, some Python keywords will just be tokenized as an identifier (like a variable name). > > But it is close enough that the authors decided against requiring a massive string to be passed in, which does amuse me. 🙃

4
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python SpongeB0B 2mo ago 83%
Installing gunicorn once on the OS and reuse it between venv ?

cross-posted from: https://programming.dev/post/17866168 > Hi, > > I use [gunicorn](https://gunicorn.org) in my [venv](https://docs.python.org/3/library/venv.html) > > I have quite few `venv` that run gunicorn. > > I would like to reuse `gunicorn` for other `venv` > > I launch my web application like this > > ```bash > #PWD = venv dir > source ./bin/activate > gunicorn A_WebApp:app > #A_WebApp is my python file A_WebApp.py > ``` > I supposes that `gunicorn` is a shell program ? if yes I should use `$PATH` ? \ > or `gunicorn` is a Python program only ? and then what I should do to use gunicorn in another `venv` ? > > Thanks.

4
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python Zara 3mo ago 100%
Do you know a CCTV software write in Python ?

Hi, I'm looking for a software similar to ZoneMinder \ https://lemmy.ml/post/18530232 But it seem that ZoneMinder become slowly outdated, php etc.. I've found a couples of alternatives ( hard choice as the limitations of use are often buried deep ) It seem that [openCV](https://pypi.org/project/opencv-python/) is really famous for AI Computer vision, So I would be surprise if there were no Python program to manage cameras like a ZoneMinder !? Do you know any ? Thanks.

10
2
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python martinn 6mo ago 100%
A library for creating fully typed declarative API clients quickly and easily
github.com

cross-posted from: https://programming.dev/post/13395352 > Would love to hear any suggestions, feedback or comments.

13
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python MichelDesmoulin 6mo ago 72%
Testing with Python (part 1): the basics
www.bitecode.dev
5
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python MichelDesmoulin 6mo ago 100%
Announcing py2wasm: A Python to Wasm compiler
wasmer.io
17
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python ylai 6mo ago 66%
Lightning Talk: Write Valid C++ and Python in One File - Roth Michaels - CppCon 2023
https://www.youtube.com/watch?v=GXwYjI9cJd0
2
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python ylai 6mo ago 88%
PEP 744 – JIT Compilation
peps.python.org
13
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python ylai 6mo ago 90%
LPython 0.21 Released For Alpha-Stage Python AOT Compiler
www.phoronix.com
9
2
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python slyuser 7mo ago 70%
Python IDLE: A Comprehensive Guide for Beginners

Unleash Your Python Potential with Python IDLE: The Ultimate Beginner's Guide! From Installation Hacks to Secret Debugging Tricks, Master Python IDLE in Minutes! 💻🚀 #Python #Programming #BeginnerGuide

4
1
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python Communist 7mo ago 100%
Help with a python script to control my lights?
github.com

I'm just trying to control my smartlights with a script, it seems to be having a lot of problems, I really don't know what I'm doing, i'd appreciate any help I can get Once I have a script that can individually turn lights on/off i can edit the rest myself, I just can't get the base functionality working.

6
6
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python bluestarshield 7mo ago 100%
Python workbook recommendations?

Hey, I've been looking to learn Python for a while, tried as a kid but got bored before I did anything. I was wondering if anyone knew of any good Python self-study workbooks? The ones with exercises in addition to theory. I'm using Mint, in case that brings up any IDE issues.

8
1
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python slyuser 7mo ago 64%
Coding a Python Program for Mm to Inches Conversion

Developed a script to perform mm to inches conversions, which was conveniently transformed into a web app using Streamlit.

4
2
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python cypherpunks 7mo ago 100%
CPython PR merged yesterday: Allow disabling the GIL with `PYTHON_GIL=0` or `-X gil=0` by swtaarrs · Pull Request #116338 (part of PEP 703)
github.com

https://peps.python.org/pep-0703/

19
1
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python ylai 10mo ago 90%
Python 3.13 gets a JIT
tonybaloney.github.io
17
3
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python McDonaldIsHealthy 10mo ago 7%
Probably unrelated

eah she's fat but so do I. I would wanna pay some Dolla to have sex before i die (very soon given my heart state) Hmu if you are interested pretty girl ![CHILD MOLESTER ](https://lemmus.org/pictrs/image/8d64c725-5b74-40a5-ad93-63047d27b1af.webp) Yeah she's fat but so do I. I would wanna pay some Dolla to have sex before i die (very soon given my heart state) Hmu if you are interested pretty girl ![CHILD MOLESTER ](https://lemmus.org/pictrs/image/8d64c725-5b74-40a5-ad93-63047d27b1af.webp) Yeah she's fat but so do I. I would wanna pay some Dolla to have sex before i die (very soon given my heart state) Hmu if you are interested pretty girl ![CHILD MOLESTER ](https://lemmus.org/pictrs/image/8d64c725-5b74-40a5-ad93-63047d27b1af.webp) Yeah she's fat but so do I. I would wanna pay some Dolla to have sex before i die (very soon given my heart state) Hmu if you are interested pretty girl ![CHILD MOLESTER ](https://lemmus.org/pictrs/image/8d64c725-5b74-40a5-ad93-63047d27b1af.webp)

-12
10
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python cypherpunks 10mo ago 80%
Python = Syntactic Sugar? Talk Python to Me Ep.441
https://www.youtube.com/watch?v=5Ff2x4_3lTI
3
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python Xer0 10mo ago 88%
What other Python communities are you part of?

Just wondering if anyone is part of any Python chats, communities, forums etc, and which ones are good to join?

7
3
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python xiffu 10mo ago 75%
Lets create a short tutorial on how to connect, create a table and insert data in SQlite with Python
www.chat-to.dev

Join chat rooms and explore programming content on Chat-to.dev.

6
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python ylai 12mo ago 76%
Pope tempted by Python! Signs off on coding scheme for kids
www.theregister.com
9
2
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python ylai 1y ago 100%
PyTorch: Compiling NumPy code into C++ or CUDA via torch.compile
pytorch.org
9
1
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python makeasnek 1y ago 100%
OSS tools for documenting database schema?

I am working on a new django project which will use a MySQL database. Obviously there are several tables and attributes items in those tables have. I realize I could just document those attributes in the code itself, but more than one codebase may be accessing this database. I would rather have a more comprehensive solution to document relationships, expected CASEing of the text, allowed characters, etc. I know UML exists, but it seems there are 1,000+ tools which do UML modeling, not all of which will gracefully do an SQL database. Examples of things I want to document: - For a "user profile" there are various attributes: username (primary key), friendly name, etc - For a "task" - id (primary key), name (letters numbers and spaces only, max 56 characters), owner (a single username (foreign key(), assignees (zero or more usernames (list of foreign keys)), etc Here's what I need: - GUI for building flowchart/model/whatever you call it showing each table and each attribute in each table, with ability to add notes to table or attribute. Attributes must have ability to be relational just like in a database. - FOSS only, must run on Linux. No "free" web-based garbage that will end up behind a paywall 5 years from now ie draw.io - Must store source files for this model in a text/xml/json/something file which can easily be put into our git repo - Must not be so tightly coupled to MySQL that is requires a database connection to work or couldn't be used if we switch to a non-MySQL backent. If it has templates for and knowledge about MySQL databases that's great but it shouldn't require them to be useful. What do you suggest for this?

7
3
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python loki 1y ago 92%
Reproducible builds for CPython source tarballs
sethmlarson.dev
12
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python ylai 1y ago 100%
The fraud was in the code
newsletter.mollywhite.net
41
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python cypherpunks 1y ago 94%
Python 3.12.0 is released
www.python.org
16
3
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python rev 1y ago 100%
PEP 703 is going to be accepted, are you ready for noGIL?
discuss.python.org

Meta is dedicating 3 engineers to get the nogil patches into cpython. There are some other companies stepping up as well. This is huge this is the closest we have ever been to solving the issue of the GIL.

23
12
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python nathanpc 1y ago 100%
Resources for someone looking into moving from other languages to Python?

Hello Python community! There are a lot of resources online targeted at beginners that want to learn Python but very rarely do you see articles talking about moving to Python when you already have tons of experience in other languages like Ruby, and especially, many years of Perl experience and is interested in moving to Python. I'm not looking for information on how to program in Python, that's really easy to find and most of the learning curve will be learning about the standard libraries and overcoming the years of muscle memory from other languages. I'm looking for information on the following topics: - What's the recommended project structure for a library or a program that'll be distributed via PyPI? - What are the general best practices to follow when writing "clean Python code"? - What's the most commonly followed style guide for the language? - How does import work internally and how does it perform its path lookup for local files (specifically for importing modules internal to a project)? - How to properly set up pyenv for a project? (This one is tricky for me because the Python community loves pyenv and I'm used to having packages globally installed in Ruby and Perl)

16
4
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python Ajsra 1y ago 100%
Coefficient of Variation in Python with Pandas & NumPy
www.marsja.se
5
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python SurpriseCandid8978 1y ago 94%
great begnner resouces to learn Python?

Hi, Does Anyone have any great resources to learn python for a non-programmer? Youtube? Free online courses, etc? Im starting out and there is a lot out there. They all look good too. So far, i got python installed lol. Thanks, Edit: thanks everyone. I have some homework to do and check out all the resources !

16
17
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python makeasnek 1y ago 100%
Question on variable scope & testing in my programs

Several years into Python, I am trying to get better about writing testable code and following the right coding conventions, and I am confused how to handle this situation. I would appreciate anybody who could lend their insight. In my code, I have functions which depend on/reference global variables. These variables *must* be global. I want to write unit tests for these functions, and in order to fully test them, that means I must be able to manipulate those global variables. Let's use this example code: ``` GLOBAL_DICT={'A':1} def my_func()->None: GLOBAL_DICT[A]=GLOBAL_DICT[A]+1 ``` I could, of course, write the function so that I can pass the global variable to it and that by default it will just add in the global variable. This makes it easier to write tests. But then PyCharm will complain that the argument is mutable and that it shadows the name from the outer scope. And if I do this, I need to define what happens if the variable is not passed (provide a default). I could set them to None, but then for doing type hinting I would have to do Union[dict,None] which makes the type hints look much more cluttered, and then pycharm will complain that I didn't handle a possible input of None in the function's code, but I shouldn't need to since I know it will never be None. ``` GLOBAL_DICT={'A':1} def my_func(GLOBAL_DICT:dict=GLOBAL_DICT)->None: GLOBAL_DICT[A]=GLOBAL_DICT[A]+1 ``` What is the best way to write these functions so they don't require passing in a bunch of globals every time I call and remain easy to write tests for?

4
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python uthredii 1y ago 83%
Check type annotations in Python with mypy
opensource.com
4
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python uthredii 1y ago 42%
Check type annotations in Python with mypy
opensource.com
-1
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python aswin 1y ago 100%
pyscan scans 200+ dependencies for vulnerabilities by the time it takes to read this.
github.com

Pyscan v0.1.4 | [GitHub](https://github.com/aswinnnn/pyscan) Pyscan is the fastest CLI tool to find dependency vulnerabilities in your python projects. + blazingly fast scanner that can be used within large projects. + automatically finds `requirements.txt`, `pyproject.toml` or, the source code. + can be integrated into existing build processes. + In its early stage, thus hasn't been battle-hardened yet. #### Install ```bash pip install pyscan-rs ``` **look out for the "-rs"** part or ```bash cargo install pyscan ``` #### Usage Go to your python source directory (or wherever you keep your `requirements.txt`/`pyproject.toml`) and run: ```bash > pyscan ``` or ```bash > pyscan -d path/to/src ``` Pyscan is a tool written in Rust that uses [OSV](https://osv.dev), which is an open source vulnerabilities database, which inspired me to make this tool.

2
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python pumpkin 1y ago 100%
Compiling typed Python
bernsteinbear.com
6
3
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python Limeey 1y ago 100%
JupyterLabs - wish I could see the notebook title like in notebooks

I switched from notebook to labs recently and I'm missing how the notebook name is displayed in notebooks. it seems like the only way to know which notebook I'm in now is through the tab, but if I have multiple tabs open it compresses them. Is there any extension or something that will display the notebook name (and make it easily editable) like in notebooks?

1
2
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python penguin_ex_machina 1y ago 100%
Python GUI Beginners Tutorial - In 30-min - Flutter For Python with Flet
https://www.youtube.com/watch?v=Tucr8Ta-kq4
4
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python pumpkin 1y ago 100%
How to Create a UTF-16 Surrogate Pair by Hand, with Python
www.oilshell.org
1
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python Veritas 1y ago 83%
Find videos with above-average popularity in YouTube subscriptions.

To find videos with above average popularity in your YouTube subscriptions, you can follow these steps: 1. Retrieve a list of your YouTube subscriptions using the YouTube API or a third-party tool. 2. For each subscribed channel, obtain the view count or engagement metrics of their recent videos. 3. Calculate the average view count or engagement metrics across all videos for each channel. 4. Compare the view count or engagement metrics of each video to the average for its channel. 5. Select the videos that have above-average view count or engagement metrics as the ones with above average popularity in your subscriptions. Here's an example code snippet in Python using the YouTube Data API to retrieve the list of subscriptions and calculate the average view count for each channel: ```python import googleapiclient.discovery # Create a YouTube API client youtube = googleapiclient.discovery.build('youtube', 'v3', developerKey='YOUR_API_KEY') # Retrieve the list of subscriptions subscriptions = youtube.subscriptions().list( part='snippet', mine=True ).execute() # Iterate through each subscribed channel for subscription in subscriptions['items']: channelId = subscription['snippet']['resourceId']['channelId'] # Get the channel's uploads playlist playlist = youtube.channels().list( part='contentDetails', id=channelId ).execute() uploadsPlaylistId = playlist['items'][0]['contentDetails']['relatedPlaylists']['uploads'] # Get the videos in the uploads playlist videos = youtube.playlistItems().list( part='contentDetails', playlistId=uploadsPlaylistId, maxResults=10 # Adjust the number of videos to fetch as needed ).execute() totalViewCount = 0 numVideos = 0 # Calculate the total view count for the channel's videos for video in videos['items']: videoId = video['contentDetails']['videoId'] videoStats = youtube.videos().list( part='statistics', id=videoId ).execute() viewCount = int(videoStats['items'][0]['statistics']['viewCount']) totalViewCount += viewCount numVideos += 1 # Calculate the average view count for the channel if numVideos > 0: averageViewCount = totalViewCount / numVideos else: averageViewCount = 0 print(f"Channel: {subscription['snippet']['title']}") print(f"Average View Count: {averageViewCount}\n") ``` You can modify this code to include other engagement metrics like likes, comments, or shares, and use them to determine the videos with above average popularity in your subscriptions.

8
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python radarsat1 1y ago 100%
How to nest context managers while hiding the dependency?

Let's say I have a context manager that provides a resource that then mutates on exit: ``` from contextlib import contextmanager @contextmanager def context(): x = ['hi'] yield x x[0] = 'there' ``` I found that if I want to make another context class that uses this, such that the context (before mutation) is valid, I have to pass it in: ``` class Example1: def __init__(self, obj): self.obj = obj def use_obj(self): print(self.obj) def __enter__(self): print("start") return self def __exit__(self, *exc): print("end") with context() as x: with Example1(x) as y: y.use_obj() ``` prints: ``` start ['hi'] end ``` However, what I don't like is, let's say that `obj` is an internal detail of my class. I don't want the user to have to define it beforehand and pass it in. The only way I can figure how to do this is by calling the context manager's `__enter__()` explicitly: ``` class Example2: def use_obj(self): print(self.obj) def __enter__(self): print("start") self.ctx = context() self.obj = self.ctx.__enter__() return self def __exit__(self, *exc): print("end") self.ctx.__exit__(None, None, None) with Example2() as y: y.use_obj() ``` which also prints, ``` start ['hi'] end ``` For comparison, just as some other random attempt, the following doesn't work because the context ends when `self.obj` is created: ``` class Example3: def use_obj(self): print(self.obj) def __enter__(self): print("start") with context() as x: self.obj = x return self def __exit__(self, *exc): print("end") with Example3() as y: y.use_obj() ``` which prints, ``` start ['there'] end ``` Okay, so my point is that `Example2` is the right solution here. But, it's really ugly. So my question is, is there a better way to write `Example2`?

2
0
"Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearPY
Python acoustics_guy 1y ago 100%
Which package/environment managers are you using?

I'm setting up a new laptop and considering which of the (many) environment managers to use this time around. My standard has been miniconda, since a big plus for me is the ability to set and download specific python version for different projects all in one tool. I also quite like having global access to different environments (i.e. environments aren't tied to specific projects). I typically have a standard `GenDataSci` environment always available for initially testing things out, then if I know I'll be continuing as a single project I'll make a stand alone environment for it. But I've also used poetry for tighter control and reproducibility when I'm actually packaging to publish on PyPI. Hatch looks interesting as well but I can't tell if it includes the ability to have separate python version installs for each environment. What workflows and managers are people using now?

2
2