Connect to a Redis cluster with Python

To connect to a Redis server with Python, one can use python3-redis module. First verify that python3-redis module is installed. I’m showing the package name in Fedora 39, if you use a different distro, then check for the relevant package name. $ rpm -q python3-redis python3-redis-4.3.3-1.el9.noarch Here is the sample code to connect to a non-cluster Redis server: import redis # Connect to Redis r = redis.Redis(host='', port=6379) # Set a key-value pair r....

April 3, 2024 · 1 min · 191 words · kenno

How to extract a zip archive with Python on Windows

Have you ever been asked or wonder how to learning a programming language? If not, then you can skip this blog post. :-) At work, a coworker said to me “I want to learn a programming language. Where do I start or how do I even start it?” I was asked this question because I had explicitly expressed my interest to my teams that I like programming a lot, though programming is not being used my professional career at the moment....

September 26, 2023 · 3 min · 466 words · kenno

Install Ansible on Freebsd

This post briefly explains how to install Ansible on a FreeBSD host. I’m going to install Ansible in a virtual environment using Python 3. (If you still use Python 2, it’s time to start migrating to Python 3 now.) $ sudo pkg install python36 $ mkdir ~/dev/python3-venv $ python3 -m venv ~/dev/python3-venv/ansible Next, activate the Python venv (ansible), and start installing Ansible using pip: $ source ~/dev/python3-venv/ansible $ pip install ansible You may or may not need to update pip module as I did....

February 21, 2019 · 1 min · 138 words · kenno

Installing Pip with Python 3.5 on FreeBSD

Here is a quick note serves as a self-reminder on how to get pip working or installed on FreeBSD 10.3. First, ensure that Python 3 package is installed. Python 3 is provided by python35 package. # pkg install python35 However, there is no package for pip, at least at the time of this writing, on FreeBSD. To have it installed, run the following command: # python3.5 -m ensurepip We should as well update pip to new version:...

May 6, 2016 · 1 min · 84 words · kenno

Python: How to convert a list to a string

There must already exist a gazillion articles about how to do this; but one more won’t hurt, right? Suppose you have a list, called alist, as the following: In [2]: alist Out[2]: ['apple', 'banana', 'pear'] To create a string from “alist” with a comma separator, we can do this: In [3]: ','.join(alist) Out[3]: 'apple,banana,pear' Basically, you can place a desired separator in the ',' or omit it totally. Reference:

August 2, 2014 · 1 min · 70 words · kenno