Aug 13, 2023
Below are the steps I followed to install Python 3.11 from my Ubuntu Linux shell. I downloaded the .tgz file from Python.org, not sure initially how to build Python from it. Once I unpacked the compressed files, I saw the build instructions in the README.rst to build a functional Python 3.11 on my Ubuntu computer. Here's how to install the speedier Python version 3.11.
How to Install Python 3.11
Use curl to download the Python gzip file.
curl https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz --output Python-3.11.0.tgz
Unpack gzip file to folder.
tar -xvzf Python-3.11.0.tgz
Change directory, read the README + find build commands.
# Build Python on Unix, Linux, BSD, macOS, and Cygwin:
sudo make install
Building Python on Various Platforms
This will install Python as python3.
You can pass many options to the configure script; run ./configure --help
to find out more. On macOS case-insensitive file systems and on Cygwin,
the executable is called python.exe; elsewhere it's just python.
Building a complete Python installation requires the use of various
additional third-party libraries, depending on your build platform and
configure options. Not all standard library modules are buildable or
useable on all platforms. Refer to the
section of the Developer Guide for current detailed information on
dependencies for various Linux distributions and macOS.
On macOS, there are additional configure and build options related
to macOS framework and universal builds. Refer to Mac/README.rst.
On Windows, see PCbuild/readme.txt.
- Python 3.11 Linux README.rst
Sep 15, 2022
There are usually many ways to do most things in Python. I've retrieved
random numbers a few different ways at various times within the random
module, often after reading a Stack Overflow post. This time in my most
recent search for random digits, I discovered in the Python docs the
function with its k parameter:
Return a k length list of unique elements chosen from the
population sequence or set. Used for random sampling without
When combined with the range() built-in,
it makes doing this easy. Being able to specify a length and return a
list of random numbers is mighty convenient. This function seems a
Pythonic way to randomize to me. Have a look!
# Returns a list of 5 random numbers.
numbers = random.sample(range(10000000), k=5)
# Returns a single random number.
number = random.sample(10000000), k=1)
To choose a sample from a range of integers, use a range() object as an
"This is especially fast and space efficient for sampling from a large
- Python Docs, https://docs.python.org/3/library/random.html#random.sample
Sep 23, 2021
Black is a code formatting tool that I have been testing out recently to see what the hype is about. It is the defacto "uncompromising code formatter in Python". I normally do not use any code formatters since I'm not required to use them. This short post aims to convince you that Black is an insightful way to see the parts of your code that are dangerously unreadable.
I have found it interesting to see what black does with my gnarliest code. It has taught me what is considered "good formatting" by some Pythonistas. The areas where I see the most improvement is how it enforces PEP-8's characters per line limit. Often before, I didn't know how to break my code into several lines. My scripts tended to have one-liners trailing off the edge of my text editor. Black teaches you new ways to organize your code and makes it easier to understand. Now I write my code like Black the first time instead of letting it trail off the screen.
Initially I was hesitant to try Black because I didn't want to sabotage my own code style. But since running Black on a few of my scripts, it has taught me new ways to write code. Give Black a chance and you will learn how to write more readable Python.
Here's the project on GitHub: https://github.com/psf/black
Sep 13, 2020
You may want to download an archive of your tweets before deleting them. I did this and it took about a day to get my archive download.
How To Purge Your Tweet History with Python
- Per the Tweepy library documentation, install tweepy with pip. It worked fine in my python 3.8 virtual environment.
pip install tweepy
- Sign up for a Twitter Developer account and create an app. I named mine "tweetcleanr".
- Find your app under "Projects & Apps". Edit your app's permissions to "Read + Write + Direct Messages".
- After you update your permissions, select the "Keys and tokens" tab. Then regenerate new API keys. Then paste them in the below script.
- Save the below script as a python file. In command prompt or terminal, run python delete_tweets.py or whatever you want to name it!
- You'll be asked to go to a link and enter an authorization code. Then you'll see your tweets being deleted like pictured below.
I found this Github Gist via Google and updated the print and input statements to Python 3. I also added the traceback module in case you need to debug it. Initially, I received an error telling me to complete step 3 above. I didn't see the error message at first, until adding traceback.print_exc() like you see below.
"""Delete All Your Tweets - Github Gist by davej
Ported to Python 3 by Lo-Fi Python: https://lofipython.com/delete-all-your-tweets-with-tweepy-and-the-twitter-api/
CONSUMER_KEY = "get_from_dev_portal"
CONSUMER_SECRET = "get_from_dev_portal"
def oauth_login(consumer_key, consumer_secret):
"""Authenticate with twitter using OAuth"""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth_url = auth.get_authorization_url()
verify_code = input(
"Authenticate at %s and then enter you verification code here > " % auth_url
"You are about to delete all tweets from the account @%s."
print("Does this sound ok? There is no undo! Type yes to carry out this action.")
do_delete = input("> ")
if do_delete.lower() == "yes":
for status in tweepy.Cursor(api.user_timeline).items():
print("Failed to delete:", status.id)
if __name__ == "__main__":
api = oauth_login(CONSUMER_KEY, CONSUMER_SECRET)
print("Authenticated as: %s" % api.me().screen_name)
✅ Twitter Cleanse Complete
Twitter has a really slick developer dashboard. Its API combined with the tweepy library got the job done for me. It's great when stuff just works. And it only cost me about 1 hour to complete. Time to start a clean slate. Here's to looking forward.
Tweepy Documentation Tutorial
Twitter's API Tutorials
Twitter Postman Tutorial