Python
- A library for creating fully typed declarative API clients quickly and easilygithub.com GitHub - martinn/quickapiclient: A library for creating fully typed declarative API clients quickly and easily.
A library for creating fully typed declarative API clients quickly and easily. - martinn/quickapiclient
cross-posted from: https://programming.dev/post/13395352
> Would love to hear any suggestions, feedback or comments.
- Announcing py2wasm: A Python to Wasm compilerwasmer.io Announcing py2wasm: A Python to Wasm compiler · Blog · Wasmer
py2wasm converts your Python programs to WebAssembly, running them at 3x faster speeds
- Lightning Talk: Write Valid C++ and Python in One File - Roth Michaels - CppCon 2023
YouTube Video
Click to view this content.
- 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
- Help with a python script to control my lights?github.com [Example request] The most basic way to turn an individual, specific light on and off · Issue #185 · mclarkk/lifxlan
I've been struggling with this for hours, i'm not a python dev, i'm just trying to control my lights with my linux pc #!/usr/bin/env python import sys from lifxlan import LifxLAN def main (): lan =...
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.
- 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.
- 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.
- 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 gh-116167: Allow disabling the GIL with `PYTHON_GIL=0` or `-X gil=0` by swtaarrs · Pull Request #116338 · python/cpython
In free-threaded builds, running with PYTHON_GIL=0 or -X gil=0 will now disable the GIL. #116322 and #116329 track follow-up work to re-enable the GIL when loading an incompatible extension, and to...
https://peps.python.org/pep-0703/
- 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?
- Lets create a short tutorial on how to connect, create a table and insert data in SQlite with Pythonwww.chat-to.dev Chat Rooms and Programming Content | Chat-to.dev
Join chat rooms and explore programming content on Chat-to.dev.
Join chat rooms and explore programming content on Chat-to.dev.
- Pope tempted by Python! Signs off on coding scheme for kidswww.theregister.com Pope tempted by Python! Signs off on coding scheme for kids
In the name of the firewall, the server, and the home page default, amen
- PyTorch: Compiling NumPy code into C++ or CUDA via torch.compilepytorch.org PyTorch
An open source machine learning framework that accelerates the path from research prototyping to production deployment.
- 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?
- The fraud was in the codenewsletter.mollywhite.net The fraud was in the code
The jury got a taste of code review as they examined a falsified "insurance fund" and the infamous FTX → Alameda Research "backdoor".
- PEP 703 is going to be accepted, are you ready for noGIL?discuss.python.org A Steering Council notice about PEP 703 (Making the Global Interpreter Lock Optional in CPython)
Posting for the whole Steering Council, on the subject of @colesbury’s PEP 703 (Making the Global Interpreter Lock Optional in CPython). Thank you, everyone, for responding to the poll on the no-GIL proposal. It’s clear that the overall sentiment is positive, both for the general idea and for PEP 7...
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.
- 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)
- Coefficient of Variation in Python with Pandas & NumPywww.marsja.se Coefficient of Variation in Python with Pandas & NumPy
Learn how to calculate the coefficient of variation in Python using NumPy and Pandas. Analyze data variability with ease!
- 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 !
- Check type annotations in Python with mypyopensource.com Check type annotations in Python with mypy
Learn more about solving common Python problems in our series covering seven PyPI libraries.
- pyscan scans 200+ dependencies for vulnerabilities by the time it takes to read this.github.com GitHub - aswinnnn/pyscan: python dependency vulnerability scanner, written in Rust.
python dependency vulnerability scanner, written in Rust. - GitHub - aswinnnn/pyscan: python dependency vulnerability scanner, written in Rust.
Pyscan v0.1.4 | GitHub
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 orbash cargo install pyscan
Usage
Go to your python source directory (or wherever you keep your
requirements.txt
/pyproject.toml
) and run:bash > pyscan
orbash > pyscan -d path/to/src
Pyscan is a tool written in Rust that uses OSV, which is an open source vulnerabilities database, which inspired me to make this tool.
- Compiling typed Pythonbernsteinbear.com Compiling typed Python
With a little effort, you can make your mypy-typed Python go zoom.
- 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?
- Python GUI Beginners Tutorial - In 30-min - Flutter For Python with Flet
YouTube Video
Click to view this content.
- 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 writeExample2
? - 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?
- Introduction to List Comprehensions
Brendan Metcalfe's intro series to list comprehensions is one of the best I've come across. In addition to showing how to use them, he compares it to other similar methods and shows why LCs can be more effective. Wanted to share his stuff here.
- This is valid Python syntax
cross-posted from: https://programming.dev/post/21515
> Some surprising, but valid, python syntax examples.
- What are the best talks about Python?
I’m looking for some conference talks about python that I could watch during some downtime at work. Give me your favorites!
- pickling large objects
I have a large object that I want to save to the disk because it takes a minute to generate. The OOM reaper kills the process while pickle.dump ing the object.
It's a tuple of dicts of tuple of array.array.
Can pickle dump in chunks? If not, is there another technique I can use?
- The Right Way to Run Shell Commands From Python | Martin Heinzmartinheinz.dev The Right Way to Run Shell Commands From Python | Martin Heinz | Personal Website & Blog
<p> Python is a popular choice for automating anything and everything, that includes automating system administration tasks or tasks that require running o...</p>
- Python adventures: Finding unused dependencies | Nathan's blogwww.nathanfurnal.xyz Python adventures: Finding unused dependencies | Nathan's blog
Introduction This article is about an issue I got a couple of times when working on medium to largish Python projects and having to deploy them. It happens quite often that the dependencies are messy and whoever is, or was working on the project happened to install a bunch of libraries because they ...