Python

Mar 01, 2023

TIL: time travel with Python’s standard library

There are a few different approaches for writing tests for date and/or time-sensitive functionality. One could choose to add a sleep() in the test, which would guarantee that the time passed, but that also has the downside of increasing the run time of the test.

Oct 25, 2022

TIL: installed packages in Python – list, and show

If your Python project has a very short list of required packages (in requirements, pipfile, etc), it’s easy to see all packages you have. But on large projects, the dependencies can run pretty long, not to mention the dependencies for the required packages. And what about learning more about those dependencies?

Jun 30, 2021

A caller id for your python function

Most of you might be too young to know this but there was time that the phone in your house - not in your pocket! - would ring and gasp! you had no idea who was calling! You had to ANSWER the phone to find out. :scream:

Sep 03, 2019

Getting started with gRPC – part I: the what

I recently spent some time researching gRPC and this post is a summary of what I learned. I also wrote a prototype application to test gRPC and gRPC-Web with Python and JS. The JS client takes a string from user input and test if it’s a palindrome. The code can be found on GitHub and in a future post I will comment on it.

Mar 08, 2019

Display nested dictionary content sorted by key in Python

Given a nested dictionary like this: dog_breeds = { 'Labrador Retriever': {'life_span': 14, 'male_weight': '36 Kg', 'female_weight': '32 Kg'}, 'Beagle': {'life_span': 15, 'male_weight': '11 Kg', 'female_weight': '10 Kg'}, 'German Shepherd': {'life_span': 13, 'male_weight': '40 Kg', 'female_weight': '32 Kg'}, 'Jack Russell Terrier': {'life_span': 16, 'male_weight': '8 Kg', 'female_weight': '8 Kg'}, 'Rottweiler': {'life_span': 10, 'male_weight': '60 Kg', 'female_weight': '48 Kg'} } here’s a way to display its content sorted by key:

Nov 30, 2018

Map a string in Python with enumerate

Problem: create a map of the letters and indices in a string. My first approach was to loop over the string using range(len(s)), and checking if the letter exists in the map before adding it:

Jun 16, 2018

Hello world!

UPDATE: At the time this post was published the blog’s name was print(f’{greeting}') What does this blog name mean?