Python

99 readers
1 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
1
2
3
4
10
submitted 1 year ago* (last edited 1 year ago) by jnovinger@programming.dev to c/python@programming.dev
 
 

Events from the Python Events Calendar:

  • Building Mico-Tech Communities Around Python Programming Language

    20 June 2023 - 30 July 2023

    Python is one of the most popular programming languages today and is used in a variety of industries, including data science, web development, artificial intelligence, and machine learning. Learning Python earlier can give you a head start in your career and make you a valuable candidate in the job market.

  • Careers with Python: Volume 2 meetup

    20 June 2023, 1:30 CEST

    PyLadies Amsterdam

    Youtube live-stream link: https://www.youtube.com/live/KO4jeWoP9bI

    Talk 1 - Python in Agricultural Technology by Neha Kalia

    Talk 2 - Python in banking by Sharanya Missula

    Talk 3 - Python in Data science and strategy consulting by Estelle Altazin

  • Dominican Republic Python User Group

    20 June 2023, 21:30 AST

    Location:

    12 Calle Eugenio Deschamps
    La CastellanaLos Prados
    Santo Domingo
    National District
    Dominican Republic
    
5
6
7
 
 

Hi,

I've discover haml and pug [^1] ( both web template engine )

It's totally Pytonic ! ( and make even more sense to use it with python rather than JS 🤮 )

I've look, if it exist for Python, but so far, I've found only

The first, only convert pug into another template :/
The second, didn't pass the alpha version.
The third, require dependence, not maintained etc.. \

So I didn't found a Python package that could do haml/pug to html directly, without too much dependence...

For example:

From

html
  head title Example for Python discuss
  body
    h1 Hello world
    p This is a paragraph.

To

<html>
  <head>
    <title>Example for Python discuss</title>
  </head>
  <body>
    <h1>Hello world</h1>
    <p>This is a paragraph.</p>
  </body>
</html>

Do you know if such thing exist ?
If not, I will build my own (FLOSS). ( I'm open to any advice to do so :) )

Thanks

[^1]:Pug is a template engine heavily influenced by Haml and implemented with JavaScript 🤮 for Node.js

8
9
submitted 1 week ago* (last edited 1 week ago) by Rick_C137@programming.dev to c/python@programming.dev
 
 

Hi,

I'm following my previous post
How encrypt email with a GnuPG public key ? [ solved ]

So I managed to encrypt the email body with GnuPG public key.. But I don't figure how I can do the same for the title ?!
ThunderBird manage it.. any idea how ?
asked on Official Thunderbird forum

Thanks.

9
 
 

From Enaml's docs:

Enaml brings the declarative UI paradigm to Python in a seamlessly integrated fashion. The grammar of the Enaml language is a strict superset of Python. This means that any valid Python file is also a valid Enaml file, though the converse is not necessary true. The tight integration with Python means that the developer feels at home and uses standard Python syntax when expressing how their data models bind to the visual attributes of the UI.

. . .

Enaml’s declarative widgets provide a layer of abstraction on top of the widgets of a toolkit rendering library. Enaml ships with a backend based on Qt5/6 and third-party projects such as enaml-web and enaml-native provides alternative backends.


A maintainer of Enaml has just opened a brainstorm discussion on the next major development goals.

It's a project I've long admired, though rarely used, and I'd love to see it get some attention and a revamp. I think the bar these days has been raised by projects like QML and Slint, which provide a great context in which to set new goals.

10
11
 
 

Note: The attached image is a screenshot of page 31 of Dr. Charles Severance's book, Python for Everybody: Exploring Data Using Python 3 (2024-01-01 Revision).


I thought = was a mathematical operator, not a logical operator; why does Python use

>= instead of >==, or <= instead of <==, or != instead of !==?

Thanks in advance for any clarification. I would have posted this in the help forums of FreeCodeCamp, but I wasn't sure if this question was too.......unspecified(?) for that domain.

Cheers!

 


Edit: I think I get it now! Thanks so much to everyone for helping, and @FizzyOrange@programming.dev and @itslilith@lemmy.blahaj.zone in particular! ^_^

12
 
 

via https://mastodon.social/@hugovk/113385974873569374

hugovk.github.io/free-threaded-wheels/ tracks how many of the top 360 PyPI packages have free-threaded wheels.

Green packages (currently 3%) offer has free-threaded wheels

Uncoloured packages (82%) offer pure-Python wheels

Orange packages (16%) have no wheels ready for free-threading (yet!)

See also Quansight Labs' https://py-free-threading.github.io/tracking/ for a smaller yet fine-grained tracker that also includes build tools.

13
14
15
16
 
 

The first post of a new python blog I started if anyone is interested.

17
 
 

I am working on a rudimentary Breakout clone, and I was doing the wall collision. I have a function that I initially treated as a Boolean, but I changed it to return a different value depending on which wall the ball hit. I used the walrus operator to capture this value while still treating the function like a bool. I probably could have just defined a variable as the function's return value, then used it in an if statement. But it felt good to use this new thing I'd only heard about, and didn't really understand what it did. I was honestly kind of surprised when it actually worked like I was expecting it to! Pretty cool.

18
19
20
21
 
 

(For context, I'm basically referring to Python 3.12 "multiprocessing.Pool Vs. concurrent.futures.ThreadPoolExecutor"...)

Today I read that multiple cores (parallelism) help in CPU bound operations. Meanwhile, multiple threads (concurrency) is due when the tasks are I/O bound.

Is this correct? Anyone cares to elaborate for me?

At least from a theorethical standpoint. Of course, many real work has a mix of both, and I'd better start with profiling where the bottlenecks really are.

If serves of anything having a concrete "algorithm". Let's say, I have a function that applies a map-reduce strategy reading data chunks from a file on disk, and I'm computing some averages from these data, and saving to a new file.

22
23
24
 
 

Hi,

I'm already using

from smtplib import SMTP_SSL
from email.message import EmailMessage

To send emails.

Now I would like to be able to encrypt them with the public key of the recipient. ( PublicKey.asc )

an A.I provide me this

import smtplib
from email.message import EmailMessage
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.ciphers.aead import AESGCM

# Load the ECC public key from the .asc file
with open('recipient_public_key.asc', 'rb') as key_file:
    public_key_bytes = key_file.read()
public_key = ec.EllipticCurvePublicKey.from_public_bytes(
    ec.SECP384R1(),
    public_key_bytes
)

# Create the email message
msg = EmailMessage()
msg.set_content('This is the encrypted email.')
msg['Subject'] = 'Encrypted Email'
msg['From'] = 'you@example.com'
msg['To'] = 'recipient@example.com'

# Encrypt the email message using the ECC public key
nonce = bytes.fromhex('000102030405060708090a0b0c0d0e0f')
cipher = AESGCM(public_key.public_key().secret_key_bytes)
ciphertext = cipher.encrypt(nonce, msg.as_bytes(), None)

# Send the encrypted email
server = smtplib.SMTP('smtp.example.com')
server.send_message(msg, from_addr='you@example.com', to_addr='recipient@example.com')
server.quit()

# Save the encrypted email to a file
with open('encrypted_email.bin', 'wb') as f:
    f.write(ciphertext)

I like the approach, only one "low level" import cryptography

but the code seem wrong. if the body has been encrypted as ciphertext I don't see this one included while sending the email.

How are you doing it ? or do you have good tutorial, documentations ? because I found nothing "pure and simple" meaning not with of unnecessary stuff.

Thanks.

25
view more: next ›