Python

6288 readers
5 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
201
202
203
9
submitted 11 months ago* (last edited 11 months ago) by [email protected] to c/python
 
 

Edit: The key was using msys2. After installing Gtk3 and PyGObject following the PyGObject guide for msys2 everything worked fine. Packaging with PyInstaller and nuitka was fine.

I've been developing an image halftoning app for a while using GTK on Linux, thinking GTK is cross platform, and delaying testing it on Windows for quite some time.

Today I decided to finally install Windows 10 (for the first time in more than a decade) on a separate machine and see what works and what does not.

For the past few hours I've been through hell trying to get GTK3 to work. I've followed multiple guides, none of which worked, including wingtk.

Furthermore, even if I successfully compile (or install) GTK, would it be possible to package it all up using something like PyInstaller or nuitka.

At this point I'm thinking of keeping the functions and writing a whole new GUI in Tk for the Windows port, as at least that seems to work.

Am I missing something?

204
205
15
submitted 11 months ago by learnbyexample to c/python
206
207
8
submitted 11 months ago* (last edited 11 months ago) by fzz to c/python
 
 

I've just create a little script to install pip in the latest Pythonista with comfort configuration, as I suppose.

This could probably be useful to someone other than me.

screenshotsIMG_0572 1 2 3


❀️‍πŸ”₯

208
5
submitted 11 months ago* (last edited 11 months ago) by [email protected] to c/python
 
 

I want to build a python package using setuptools. The folder structure of the project is the following (some non-essential parts have been deleted):

energy-monitor
β”œβ”€β”€ config
β”‚ β”œβ”€β”€ config.yml
β”‚ └── secrets.yml
β”œβ”€β”€ data
β”‚ └── cpu_tdp.json
β”œβ”€β”€ energy_monitor
β”‚ β”œβ”€β”€ core
β”‚ β”‚ β”œβ”€β”€ gui.py
β”‚ β”‚ β”œβ”€β”€ __init__.py
β”‚ β”œβ”€β”€ data
β”‚ β”‚ └── tableExport.json
β”‚ β”œβ”€β”€ __init__.py
β”‚ β”œβ”€β”€ main.py
β”‚ └── utils
β”‚     β”œβ”€β”€ api_calls.py
β”‚     └── __init__.py
β”œβ”€β”€ energy-monitor.py
β”œβ”€β”€ LICENSE
β”œβ”€β”€ MANIFEST.in
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ README.md
└── requirements.txt

The content of the pyproject.toml file is the following (some non-essential parts have been deleted):

[build-system]
requires = ["setuptools>=68.0"]
build-backend = "setuptools.build_meta"

[project]
name = "energy_monitor"
version = "0.0.1"
description = "Energy monitor"
readme = "README.md"
requires-python = ">=3.11"
license = {text = "GPLv3"}
classifiers = [
  "Programming Language :: Python :: 3",
  "Operating System :: OS Independent",
]
dynamic = ["dependencies"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools]
packages = [
  "energy_monitor", 
  "energy_monitor.core", 
  "energy_monitor.utils"
]
include-package-data = true

[project.scripts]
energy-monitor = "energy_monitor.main:main"

Finally, the content of the MANIFEST.in file is the following:

include README.md
include LICENSE
graft config

I generate the package with python -m build and install the .tar.gz archive with pipx. According to setuptools documentation, I expect to find my config folder, together with README and LICENSE in the interpreter directory (site-packages) after the installation. However, this doesn't happen and I cannot run the app becase it complains that it doesn't find the config. What am I missing?

209
210
211
 
 

I can't give you the code because this is work related, and I couldn't make a minimal code that mimics the behavior.

My of my programs at work is a log parser, it reads syslog and use compiled regex pattern to match syslog, the whole program looks like this

If match := pattern.match(line):
  Do this
elif match := pattern2.match(line):
  Do that
…

During almost two years of me developing the programs, there are more patterns and more things to do and it gets slower.

But I recently figure out that if I commented out Do that and replace it with pass, my program speeds up, even if pattern2 never matches in my test case.

More strange thing is that in my attempts to use cProfile to profile things, my program runs 2.5x to 3x faster by just doing

from cProfile import Profile
with Profile() as profile:
  main()

I don't even call anything with profile variable and it speeds up my program, why is that?

212
213
 
 
  • Python 3.12 support.
  • Python 3.7 is no longer supported.
  • Shiboken generator is now available on PyPI.
  • Better asyncio compatibility.
  • Better Android compatibility.
  • aarch64 architecture is now supported.
  • Better access to commercial wheels.
  • Better Python integration in Qt Creator.
  • Out to date research plan for dynamic binding.
214
215
 
 

The thing I love about python is it's elegance; and I thing that is partially due to its syntactic sugar. Between list comprehensions, destructuring, enumerators, generators with yield, and a bunch more, what is your favorite

216
2
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/python
 
 

#XMPP + #Google Summer of Code 2023

Edward initiated discussion session on "Communication & Messaging of the #Future" with 9 participants.

We discussed connection of platforms, importance of information, cultivating community, influence of #AI and #healthy communication. Great exchange!

@RocketChat @python @gnuoctave SociΓ©tΓ© des arts technologiques #openmrs

#chat #gsoc2023
#interoperability #federation #jabber #standards

217
 
 

I'm talking about stuff like this: [file.unlink() for file in files] instead of the more verbose but maybe easier to grasp for python noobs:

for file in files:
    file.unlink()

Maybe with a bit more context:

def _cleanup(self) -> None:                                                                                                                                                                                                             
    dirs, files = partition(lambda f: f.is_file(), self._tmp_dir.rglob("*"))                                                                                                                                                            
    [file.unlink() for file in files]                                                                                                                                                                                                   
    [dir.rmdir() for dir in dirs]                                                                                                                                                                                                       
    self._tmp_dir.rmdir()
218
219
220
13
Calling Rust from Python (blog.frankel.ch)
submitted 1 year ago by [email protected] to c/python
221
 
 

How to take a few images and create custom graphics with Pillow - memes, info-graphics, custom banners and the like.

222
 
 

Examples of how to use amateur astrophotography and machine vision USB cameras with Python (or IronPython sometimes).

223
224
225
view more: β€Ή prev next β€Ί