Antonio One

@antonio_one
16 Followers
24 Following
178 Posts

This is an experiment account, where I'm posting random python tips for geeks for fun.

Most posts are created using automation. The code blocks are evaluated and quality checked to a certain extent but they are far from perfect.

If you find smelly code, please let me know and I'll remove/fix it.

In the meantime I'm working on fine-tuning this process.

Any "haters" will be blocked.

Twitterhttps://twitter.com/eno_oinotna
Websitehttps://www.antonio-one.dev
LinkedInhttps://www.linkedin.com/in/antonioone/
Using oauthlib.oauth2.rfc6749.clients.web_application and prepare_grant_uri in python to create a web application that authenticates and authorizes users with an OAuth 2.0 provider.
#python #oauthlib #oauth2 #rfc6749 #clients #web_application #3.2.2
The urllib3.response module in Python is used to handle HTTP responses. We can use is_response_to_head to check if the response was obtained from a HTTP HEAD request.
distutils.dep_util and newer can be used in Python to check if a target file/directory is newer than a given source file/directory, enabling efficient checking of file dependencies.
#python #distutils #dep_util #3.11.5
Python hashlib and new can be used to calculate and verify the integrity of file downloads or to securely store and compare passwords.
#python #hashlib
Use case: Creating a named tuple with custom attributes. By using attr._make, a tuple is created with values and then set_closure_cell is used to assign values to the custom attributes. #python #attr #_make #23.1.0
jinja2.environment and lru_cache can be used together to cache expensive template rendering. #python #jinja2 #environment #3.1.2
The `blinker._utilities` module provides utility functions. One use case is to get all subscribed receivers for a signal using `blinker._utilities.receivers`. #python #blinker #_utilities #1.6.2
A simple use case for flask.helpers.abort is to handle an invalid user input by instantly terminating the request and returning a custom error code and message. #python #flask #helpers #2.2.5
A simple use case of signal and valid_signals is to handle a user interrupt signal (SIGINT) to gracefully stop a Python script execution. #python #signal
Use functions_framework and cloud_event to build a simple serverless function that receives HTTP requests and converts them into CloudEvents, allowing seamless integration with event-driven architectures. #python #functions_framework