Sep 18, 2023
There have been countless obituaries about RSS on the internet, like when Dan McKinley wrote that "Google Reader Killed RSS". For sure, the existence of Google Reader had an impact on other readers gaining a wider audience before it was shut down by Google. This likely did have a suppressive impact on the adoption of RSS.
"Whatever happened to RSS?" is a question that murmurs thorugh the internet. The answer: it's still here and it's not going anywhere. I propose that RSS is not dead, but quietly regaining its strength and is on track to relevancy again. But did it actually fall off?
Did you know? RSS stands for "Really Simple Syndication".
Some say with the rise of social media and email newsletters, RSS is not worth the time. That's precisely what the social media and search engine giants want so you'll stay in their walled garden platform. Google killed Google Reader because it is not in their interests to support a syndication format that cuts out their search engine middleman role. Nonetheless, we only need to consciously choose to use RSS to bring it back to prominence. Who's with me?!
"RSS readers have not only survived in the era of social media,
but are driving more and more attention back to themselves, as people are realizing the pitfalls"
- Brian Barrett. "It's Time for an RSS Revival". Wired. https://www.wired.com/story/rss-readers-feedly-inoreader-old-reader
You'll often hear the term "aggregator" or "reader" when dealing with RSS, which both mean "tool that collects multiple RSS feeds into single readable format". There are plenty of free RSS reader websites to keep up with new material from your favorite websites. Currently, I use Feeder to keep up with the blogs I follow. Their free plan allows you to follow up to 200 RSS feeds for free. Feedly is a commonly suggested RSS reader also.
A Few Benefits of RSS
Receive notice when a new post is published by your favorite websites and blogs.
The personal data of your readers is not collected.
An RSS subscription is less intrusive compared to blasting into someone's cluttered email inbox. Plus you won't end up in the spam folder.
Diversify your website's traffic to be less dependent on search engines and social media platforms.
To know approximately how much RSS traffic you have, check how many HTTP requests have an XML content type.
This blog post has a good breakdown of this HTTP based approach.
Typically, 3-5% of total HTTP requests on my blog have XML content type, indicating RSS traffic.
Sep 14, 2023
Python events and conferences are a great way to learn about a niche problem someone solved, new libraries in the ecosystem or general programming topics. Here are some of the best events I've found or experienced related to Python.
The events on this list can be either a live, in-person conference, smaller meetup or an online conference or seminar. Most events will post their talks on YouTube so it's easy to look up interesting talks and watch them for free.
This power ranking is meant to be in good fun and not taken too seriously. I ranked them according to the popularity, cost effectiveness (less $ to learn is better) and usefulness of the event for the average Pythonista. For example, DjangoCon is a very popular conference, however it is focused on a particular web framework so not as widely applicable as other events.
Python Events Power Ranking
PyCon (insert local country or city here) aka Python conferences: PyCon US is probably the best known of this type of Python event. Many countries, cities or regions have a local version of their Python conference. There's EuroPython for all of Europe, individual countries like PyCon Portugal, PyCon Amsterdam, PyCascades (US Pacific Northwest region), PyCon Latam, Kiwi PyCon (New Zealand), PyCon Singapore, PyCon Hong Kong, PyCon Atlanta, PyTexas, PyBeach (Los Angeles) and so on. There are so many PyCon-like options and this is barely scratching the surface. Sometimes these events include longer training sessions in addition to shorter talks. I frequently watch the talks posted to the PyCon US YouTube channel every year. It's a good option if you don't mind waiting weeks or months for them to drop the videos.
Python "User Group" Meetups: often you can find free events that host a speaker or two locally. These are less intensive than a full conference and maybe last a few hours. User groups are a more chill way to learn and connect with your fellow Python developers. Shout-out to ChiPy, the Chicago Python user group I attended that hosts regular meetups monthly.
There about 1,637 Python user groups worldwide in almost 191 cities, 37 countries and over 860,333 members.
- https://wiki.python.org/moin/LocalUserGroups
PyData: these scientific computing conferences showcase fascinating work from data professionals. I've watched a ton of PyData talks. They run these conferences in various cities and regions. Check out the PyData YouTube channel for technical talks. PyData is recommended by the SciPy project as well according to their website.
Pyjamas: "the coziest Python conference of them all", this online conference had a very casual format to watch Python talks. The diversity of hosts and speakers from across the globe brought a wide range of perspectives that I enjoyed. The event had lots of engaging talks. It was one of my favorite Python events I've seen. Check out Pyjamas for a cozy online conference experience, I hope they continue to put it on! You can watch past talks on their YouTube channel also.
Python Web Conf: this 5 year old online conference boasts "top names in the Python community" and lasts for 5 days. In addition to typical Python talks, it includes "lightning talks" and "end of day socials". You can watch 80 videos from Python Web Conf 2023 on YouTube. This event is run by Six Feet Up, a woman-owned company.
PyLadies Con + PyLadies Meetups: PyLadies is "a group of women developers worldwide who love the Python programming language.", per their website. In addition to their annual online conference, they host local meetups all over the world. Shout-out to all the women Python developers out there!
DjangoCon: Django is a popular Python web framework for building websites. This conference is tailored for Django developers and those who want to explore one of Python's most robust web frameworks. While searching for DjangoCon events, I found conferences like DjangoCon US, DjangoCon Europe and DjangoCon Africa. If you want to see what it's like, you can watch the past DjangoCon talks on their YouTube channel.
SciPy: another annual Python conference to stoke your scientific computing prowess. The SciPy conference is held annually, with a few variations like EuroSciPy, SciPy Japan and SciPy India. It's also associated with the SciPy library, an open-source software for mathematics, science, and engineering. However the SciPy library project's website states, "The SciPy project doesn’t organize its own conferences." Check the SciPy Calendar for local meetups also.
The Python community hosts a cornucopia of events and conferences. Go to them and learn in person or stay home and watch online. That's all for now, I hope you found Python events you didn't know about. Now go learn something new!
Python Events Resources
Interactive Visualization of Python Events
PyCon.org Events Calendar
Python.org Conferences Wiki
Python.org Conferences and Workshops
Python Training Events
Aug 13, 2023
Below are the steps I followed to install both Python 3.11 and Python 3.12 in my Ubuntu Linux shell.
Make sure to adjust your Python version to match 3.11 or 3.12 in all commands.
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 versions 3.11 or 3.12.
How to Install Python 3.11 or 3.12
Install Linux build libraries.
I followed this step posted on this blog.
If you don't do this, you'll likely see an error about C not being found when running the ./configure command.
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev
Install sqllite Libraries (Django Requirement)
If you wish to make a Django website, install sqllite libraries before you build Python.
sudo apt install sqlite3 libsqlite3-dev
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.
cd Python-3.11.0
cat README.rst
Build Python.
# Build Python on Unix, Linux, BSD, macOS, and Cygwin:
./configure --enable-optimizations
make
make test
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
Install dependencies
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
Aug 07, 2023
Most text editors can open files from a computer's command line shell. Here are 8 different text editor commands for opening a file:
IDLE (Python's Built-in Editor)
idle file.py
image source: IDLE documentation
Sublime
subl template.rst
VS Code
code file.py
Atom
atom file.py
Emacs
emacs -nw file.txt
source: Stack Overflow user Anthon
Notepad++
start notepad++ file.py
source: W3 Schools
TextEdit
open -a TextEdit file.txt
source: Stack Overflow user robmathers
Vim
:e file.txt
source: confirm blog
The ability to quickly pop open and view a file is essential. Ubuntu has the cat command to print a file's contents to the terminal screen also if you don't need to edit it. Tools like sed and awk are useful for command line file editing if you prefer to keep it in the terminal.
Want to read more about text editors? Check out my text editor file size comparison here.
Jul 27, 2023
The world's game is fun to watch. It's obvious when a team is dominant against a weaker opponent. What gives one team an edge over another? Is it short, crisp and reliable passing resulting in a high conversion percentage? Or shots on goal? Quality touches. Clinicality in the final third is what separates the champions from the rest. Making the most of your chances. Apparently, some of the best teams keep their passes on the ground. All of these things contribute to victory in a sense.
We all have our theories to what makes a great player or team. But how do we assess football performance from an analytics perspective? It is difficult to predict how teams with varying styles will match up. Fortunately, data is integrating with the football world. Extensive analytics resources and tactics now available for free online.
If you're interested in football analytics, there seems to be a few areas you can go. Do you need to collect data? If you can record a game correctly, it can be converted into data from which winning insights are extracted. If you are lucky enough to already have data, what does it say about player and team performance? Can you study open data from professional teams to explore your hypotheses?
Searching the internet, FC Python was the first thing I saw. They have some free tools available for collecting data from live games. I was impressed at the Python code for pitch heat maps to track Abby Wombach's passing. Their example uses seaborn and matplotlib:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Arc
import seaborn as sns
%matplotlib inline
data = pd.read_csv("Data/passes.csv")
data.head()
fig, ax = plt.subplots()
fig.set_size_inches(14, 4)
# Plot One - distinct areas with few lines
plt.subplot(121)
sns.kdeplot(data["Xstart"], data["Ystart"], shade="True", n_levels=5)
# Plot Two - fade lines with more of them
plt.subplot(122)
sns.kdeplot(data["Xstart"], data["Ystart"], shade="True", n_levels=40)
plt.show()
# Create figure
fig = plt.figure()
fig.set_size_inches(7, 5)
ax = fig.add_subplot(1, 1, 1)
# Pitch Outline & Centre Line
plt.plot([0, 0], [0, 90], color="black")
plt.plot([0, 130], [90, 90], color="black")
plt.plot([130, 130], [90, 0], color="black")
plt.plot([130, 0], [0, 0], color="black")
plt.plot([65, 65], [0, 90], color="black")
# Left Penalty Area
plt.plot([16.5, 16.5], [65, 25], color="black")
plt.plot([0, 16.5], [65, 65], color="black")
plt.plot([16.5, 0], [25, 25], color="black")
# Right Penalty Area
plt.plot([130, 113.5], [65, 65], color="black")
plt.plot([113.5, 113.5], [65, 25], color="black")
plt.plot([113.5, 130], [25, 25], color="black")
# Left 6-yard Box
plt.plot([0, 5.5], [54, 54], color="black")
plt.plot([5.5, 5.5], [54, 36], color="black")
plt.plot([5.5, 0.5], [36, 36], color="black")
# Right 6-yard Box
plt.plot([130, 124.5], [54, 54], color="black")
plt.plot([124.5, 124.5], [54, 36], color="black")
plt.plot([124.5, 130], [36, 36], color="black")
# Prepare Circles
centreCircle = plt.Circle((65, 45), 9.15, color="black", fill=False)
centreSpot = plt.Circle((65, 45), 0.8, color="black")
leftPenSpot = plt.Circle((11, 45), 0.8, color="black")
rightPenSpot = plt.Circle((119, 45), 0.8, color="black")
# Draw Circles
ax.add_patch(centreCircle)
ax.add_patch(centreSpot)
ax.add_patch(leftPenSpot)
ax.add_patch(rightPenSpot)
# Prepare Arcs
leftArc = Arc(
(11, 45), height=18.3, width=18.3, angle=0, theta1=310, theta2=50, color="black"
)
rightArc = Arc(
(119, 45), height=18.3, width=18.3, angle=0, theta1=130, theta2=230, color="black"
)
# Draw Arcs
ax.add_patch(leftArc)
ax.add_patch(rightArc)
# Tidy Axes
plt.axis("off")
sns.kdeplot(data["Xstart"], data["Ystart"], shade=True, n_levels=50)
plt.ylim(0, 90)
plt.xlim(0, 130)
# Display Pitch
plt.show()
|
Impressive use of matplotlib and seaborn! This code is meant for a Jupyter notebook. I can't find the "passes.csv" data but suspect it is using statsbomb. It's a free footy dataset that's on display in this Towards Data Science blog post also.
In another practical example of wrangling data, Tactics FC shows how to calculate goal conversion rate with pandas. I'm guessing basic statskeeping and video is collected in great quantities by analytics teams during games for professional teams. At half time, typically on TV they will show both teams' shots, passes and time of possession.
Another intriguing field of study is extensive simulation and tracking of individual player position on the pitch. Google hosted a Kaggle competition with Manchester City 3 years ago, where the goal was to train AI agents to play football. Formal courses are available like the Mathematical Modeling of Football course at Uppsala University. There's also the football analytics topic on Github that shows 100+ repos.
From that topic, I found Awesome Football Analytics, which is a long list of resources to browse through. It seems wise to stop through Jan Van Haren's soccer analytics resources. I'm really looking forward to checking out Soccermatics for Python also. There is a ton of stuff online about football analytics that is happening.
I sense there is a passionate community pushing football analytics forward and innovating. There are many facets to consider from video optimization, data collection, drawing insights from established datasets, tracking game stats and codifying player movements.
Techniques like simulation and decoding live games into data could result in recommendations for players to uncover new advantages, adjust their positioning, conserve their energy or look for chances in a vulnerable spot on the field. The best teams are probably asking how they can leverage data to inform their strategy on the pitch and win more games.
Watching football is so satisfying. Why not study it with Python? My prediction is that the beautiful game will progress and improve as teams develop a more sophisticated data strategy.
Jul 23, 2023
Linters exist for almost every kind of structured document. Python code, SQL, reStructuredText and many data formats can be improved
with a linting library. Python's ecosystem has no shortage of formatters and linters.
In this post, I'll highlight the typical players and some niche linters you might not have heard of! The best quality of linters is
their ability to find potential problems in your code by enforcing domain-specific rules. In return, you receive a list of hints for
fixing anti-patterns, inconsistencies or unused code to remove. Many linters also offer document reformatting capabilities like the
ubiquitous black library for Python code.
Python Linters and Formatters You Gotta Know
ruff: the lean and fast linter library that's gotten a lot of people's attention.
For good reason, it's the easiest and fastest Python code linter, running rust under the hood. In my experience, using ruff
has made me a more efficient Python programmer. The ruff CLI's --fix argument is a nice touch for automatically fixing up your code.
In addition to linting, ruff also now includes Python's fastest built-in formatter!
ruff format is a high performance drop-in replacement for black.
Run ruff on your Python script for quick and easy linting.
pip install ruff
ruff check do_stuff.py
# Find Python code errors and fix them with ruff.
ruff check do_stuff.py --fix
Run ruff format on your Python script for fast code formatting.
black: a must-mention, this Python code formatter with some linting-like qualities if your code has syntax errors.
Typically, I run it on every script I write, but might consider using ruff format instead!
ruff format do_stuff.py
Reformat your code with black.
pip install black
python -m black do_stuff.py
Lint code for security vulnerabilities with Bandit.
Bandit is a linter that checks your Python script for security vulnerabilities.
pip install bandit
bandit -r your_script.py
Lint + format SQL code with SQLFluff.
sqlfluff: "The SQL linter for humans", sqlfluff is a linter and code reformatting tool to tidy up your database queries. sqlfluff does the little things like uppercase your keywords, add whitespace where appropriate, check syntax and in general clean up your scripts. The CLI is configurable for nearly all dialects from DuckDB, T-SQL, Redshift, MySQL, to SQLlite and more. Check the sqlfluff Github repo for all their supported SQL dialects or use the sqlfluff dialects command to list them in your shell. This is the library I want to tell every Python programmer about right now, along with ruff. SQL is everywhere, we all use it. SQL linters are not something most people even know exist. Next time you need to fix a broken SQL script or clean up some legacy code, enter this into your shell:
pip install sqlfluff
# Lint your SQL code.
sqlfluff lint stuff.sql
# Fix your SQL file in the PostgreSQL dialect.
sqlfluff fix stuff.sql --dialect postgres
# Check available SQL dialects.
sqlfluff dialects
json.tool: a Python standard library CLI tool with JSON validation abilities. If you're working with json, remember this stock Python tool.
Validate JSON with a built-in python CLI tool.
echo '{1.2:3.4}' | python -m json.tool
Use pylint to improve to improve your Python scripts.
pylint: commonly used static code analyser that enforces PEP-8 and other rules in your code.
pip install pylint
pylint do_stuff.py
Lint your YAML files with yamllint.
yamllint: YAML is unavoidable as a configration staple in tons of modern software.
It gets heaps of praise for its readability. I appreciated yamllint's instrospective linter when trying to figure out why my YAML config was broken.
pip install --user yamllint
yamllint config.yaml
Lint and reformat your .rst documents.
rstfmt and restructuredtext-lint (read more): Both of these reStructuredText format linter libaries offer code reformatting and linting abilities for reStructuredText files (.rst). I favored restructuredtext-lint, due to its rst-lint CLI tool. I used it to fix and tested it on old posts from this blog. Beware that using a reformatter might surface buried errors found by linting the RST, which you'll need to resolve by reading somewhat cryptic RST error messages given by your linter like "hyperlink mismatch, 1 reference but 0 targets". At least the line number is provided so you have a relative scope of where the error is coming from. rstfmt is another Python CLI tool in this space. One note of using these tools is to watch out for unwanted changes. One effect I saw was having code blocks auto-converted from Python formatting to regular code formatting.
pip install restructuredtext-lint
rst-lint post.rst
Lint your Markdown documents.
pip install pymarkdownlnt
pymarkdown scan example.md
Lint your HTML documents.
pip install html-linter
html_lint.py filename.html
Pelican + .rst or .md
RST is one of two pelican-import command line tool conversion options by the Pelican static site generator library, along with Markdown (.md). RST is the format this blog is composed in. Pelican has linting-like functionality when you run its pelican content command to compile your static site.
Although I haven't used them personally, it's worth mentioning popular libraries like pyflakes and flake8 for linting Python code. ruff supports some of these libraries also. Check out pymarkdownlint for linting Markdown documents. While researching for this post, I even stumbled upon an HTML linting command line tool that exists. html-linter applies linting to your HTML code. Starting to think that behind every seasoned Python programmer is a thick stack of linters! When it comes to fixing and refactoring old documents and code, linters and auto-formatters go hand in hand as invaluable tools.
Supplementary Reading + Documentation
7 Python libraries for more maintainable code
reStructuredText documentation
sqlfluff CLI documentation reference
Jul 09, 2023
Recently, this blog switched to Cloudflare Pages after years of hosting on WordPress. I'm now using the free plan and enjoying the various settings that allow you control aspects of security at a level not found in WordPress.
For example, you can activate the "bot fight mode", "browser integrity check" and "user agent blocking" settings to help you fend off bad actors.
Enable bot fight mode.
Run a speed test on your blog.
Turn on search engine hints.
See which search engines are crawling your blog.
Here are my top Cloudflare Pages features:
- Zone analytics: the primary analytics to view unique visitors count, requests, bandwidth and network error logging
- crawler hints: turn on hints to search engine crawlers and avoid wasteful compute
- bot fight mode: enabling this mode will stop malicious bots
- security center scan: validates your DNS configuration and tells you if anything needs fixed
- run a speed test: test your site's speed
- enable IP geolocation: includes the country code for each blog visitor
- GraphQL API: extensible analytics HTTP API
- AMP real url: ask Google to show your site's actual url in AMP
- notifications: set email alerts to monitor your website
- security events log: monitor managed challenges and bots
- browser integrity check: looks for common http headers abused by spammers
- user agent blocking: blocks users with malicious user agent
- 0-RTT Connection Resumption: enable "0-Round Trip Time", optimized DNS for your blog
- DNS Analytics: see DNS traffic visualizations
- Onion Routing: serve your website's content in a tor-friendly way
These are all included in the free plan. Some are enabled out of the box and others need to be toggled on to activate. I'm really digging my two Cloudflare Pages blogs. It's taken some time to get used to writing in reStructuredText format. Using pelican for static site generation is working well.
One quirk of Cloudflare is that only the past 30 days of data is stored. It's not as convenient as Wordpress, which stores the entire analytics history of a blog's traffic. However, Cloudflare's GraphQL API is also an option for your data querying needs. Regardless, I'm very impressed at the level of configuration Cloudflare exposes out of the box!
May 17, 2023
While running Python version 3.8.10 today, out of the blue I saw this error attempting to pip install a package in my virtual environment:
ERROR: Cannot perform a '--user' install. User site-packages are not visible in this virtualenv.
I found a Github thread that fixed the problem! You need to update your pyvenv.cfg in order to resolve this conflict.
Here is how to fix your Python environment from Github user jawalahe:
- Go to the pyvenv.cfg file in the virtual environment folder.
- Set include-system-site-packages to true and save the change.
After completing this, my pip installs worked again and no longer returned the error.
May 15, 2023
This blog is formerly known as "Python Marketer" from 2016 to 2023. In
May 2023, I've begun the migration from Wordpress's "Personal" plan to a
free, Pythonic Pelican static site.
100 posts are now hosted here exclusively on lofipython.com.
I will be posting my projects, Python explorations and technical notes
here going forward. Thank you for reading and I hope you
enjoy these Python musings. If you want to keep up with my writing, I
recommend using an RSS reader to follow the RSS or Atom feeds.
I've decided to continue blogging under a new Python moniker
which is more fitting of who I am as a Pythonista in 2023. WordPress
gave me my start as a blogger before I had the capabilities to make my
own. Now, I've switched from their "Personal" plan to a Pelican +
Cloudlare Pages free plan blog stack. It's going great so far and will
save me $48 per year vs. WordPress. Not to mention, I have a hard backup
of all my content and host it on Github! I'm no longer dependent on a
paid blogging platform to serve my blog. Huge win all around. Here's to
whatever Python projects are next!
The Next Chapter: Lo-Fi Python
Lo-fi (also typeset as lofi or low-fi; short for low fidelity) is a
music or production quality in which elements usually regarded as
imperfections in the context of a recording or performance are present,
sometimes as a deliberate choice. Wikipedia
The Spirit of Low Fidelity
Lo-Fi Python aims to find the "lo-fi" spirit of Python. Doing more with
less. Favoring the standard library. Lowest possible time to MVP
(minimum viable product). Learning new libraries. Exploring the
ecosystem with playful curiosity. Embrace helping others by helping
yourself. This is the way.
Feb 26, 2023
Today, I was granted access to Bing's large language model, the next generation GPT-4. Bing's chat is the "more powerful" successor to OpenAI's groundbreaking chat service that's generating heaps of hype in addition to its AI text generation abilities. I gained the new chat functionality a few weeks after joining the Bing waitlist.
A guilty pleasure of mine is fixing up old Windows machines by installing updates and running command prompt tools like SFC and chkdsk. There's also GUI based tools like disk cleanup and the disk defragmenter.
My HP computer on Windows 10 is running slow and steady. It's an old model, so I want to improve performance wherever possible and hopefully speed it up. Enter Bing. It did what I wanted and more, but I needed to rephrase my first question to get better results.
First, I asked how to improve performance on a Windows computer. Bing offered generic windows maintenance tips, then followed up to ask my operating system version, which is Windows 10. When I informed Bing it offered more targeted advice after I rephrased my question to focus on command line commands.
I then asked a new question in a fresh chat session. This time I included my OS and asked more specifically for Windows command prompt commands for improving performance. Bing listed a few options and gave a little context of what they do. Then I was presented options to show how to use powercfg or msconfig.
How to use powercfg according to Bing:
Bing chat helped me find and remember the SFC /scannow command. It caches copies of files, fixes corrupted files and may speed up your machine.
You can even prompt Bing for detailed examples of how to use specific windows commands. To get this kind of result from a search engine is incredible. It's like Bing is your own personal tutor. As someone who is constantly googling how to do computer and programming related things, this feels impressive. This was my first time using this service and it has raised the bar for searching the web. I then prompted Bing for a Python script capable of running the SFC command and had my first "wow" moment.
Then it asks if I want the Python code explained. I'm so chuffed at this point. It tapped the subprocess module to write the script and capture its output. Simply stunning.
SFC requires an administrator command prompt. You can start an admin command prompt from the start menu. I ran "python run_sfc.py" containing the below script on version Python 3.11. The command finished running approximately 20 minutes later. Additionally, if you get the error 'utf-8' bytes can't be decoded, you'll need to pass an encoding argument to decode(). Ok, here's the Python script:
| # Import the subprocess module
import subprocess
# Define the SFC command as a list of arguments
sfc_command = ["sfc", "/scannow"]
# Run the SFC command using subprocess.run and capture the output
sfc_output = subprocess.run(sfc_command, capture_output=True)
# Print the output of the SFC command
print(sfc_output.stdout.decode())
|
If your text is using a non-English character encoding, I found you may need to pass a different encoding besides the default utf-8. For example, I found this to work if your command prompt characters are in Spanish:
| # en español
print(sfc_output.stdout.decode(encoding="latin-1"))
|
You could also use a Windows batch file of course: