Categories
python

Python: Check how long a HTTPX Request took to run?

To check the response time of a python httpx request, use the response.elapsed attribute. import httpx client = httpx.Client() response = client.get(‘https://stoicquotesapi.com/v1/api/quotes/random’) print(response.elapsed.total_seconds()) This will print out the response time: 1.334806 Again: response.elapsed.total_seconds())

Categories
python

Python: Print all modules and packages available on the python path

When working with python a ImportError or ModuleNotFoundError: No module named 'xxx' may arise. This error usually means that the script or python file you are running does not know about a module you are importing. How can we get a list of modules that are accessible? Using Sys Modules This gets all package modules […]

Categories
python

A review of ____ Python Books

I like python. It is a great programming language with great conventions and a great community. It has been a close ally and friend over the years. There are many books out there that teach python or cover topics within python. Many of them are titled "____ Python" or "XXXX Python" or "Your word Here […]

Categories
aws python

How to View AWS Lambda Event Data?

Wondering how to actually view the event data your lamba function received? With python. In this post a solution is proposed. Other search phrases: View aws lambda event data aws lambda view event data Viewing AWS Lambda Event Data Create a new lambda with the permissions and trigger you need and call it test-debug-<myproblem> I […]

Categories
ubuntu python

Initial Setup of a Ubuntu 20.04 VM with Compiled Python 3.10

Assuming you have logged in as root with a password Creating a non-root User adduser ubuntu usermod -aG sudo ubuntu Add your SSH key to the new User ssh-copy-id ubuntu@ ssh ubuntu@ Enabling Firewall sudo ufw app list sudo ufw status Disable root login and password based login sudo vim /etc/ssh/sshd_config Uncomment and set: PasswordAuthentication […]