<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Simo Leigh</title>
    <description>The latest articles on Forem by Simo Leigh (@simon_jhon).</description>
    <link>https://forem.com/simon_jhon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2751726%2F9a83d115-7a34-4250-9471-61dfd7a09fb9.jpg</url>
      <title>Forem: Simo Leigh</title>
      <link>https://forem.com/simon_jhon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/simon_jhon"/>
    <language>en</language>
    <item>
      <title>From Scripting to AI Python's Journey Through Time and Code</title>
      <dc:creator>Simo Leigh</dc:creator>
      <pubDate>Sun, 02 Nov 2025 16:04:00 +0000</pubDate>
      <link>https://forem.com/simon_jhon/from-scripting-to-ai-pythons-journey-through-time-and-code-18o3</link>
      <guid>https://forem.com/simon_jhon/from-scripting-to-ai-pythons-journey-through-time-and-code-18o3</guid>
      <description>&lt;p&gt;Hey there, Pythonistas and curious coders! &lt;/p&gt;

&lt;p&gt;Python has undergone a remarkable transformation. It started as a humble scripting language to automate system tasks for Guido van Rossum and has since exploded into a dominant force in web development, data science, machine learning, and beyond.&lt;/p&gt;

&lt;p&gt;Let's time-travel through Python's history, comparing how we used to write code with how we write it today. The evolution is nothing short of incredible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 1: The Early Days (Python 1.x - 2.4) - The Scripting Prodigy&lt;/strong&gt;&lt;br&gt;
In the beginning, Python was all about readability and simplicity. It was a powerful alternative to Perl and Bash for system administration, file processing, and small scripts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Example: The Classic Python Script (circa 2000)&lt;/strong&gt;&lt;br&gt;
`# process_logs_old.py - A typical admin script&lt;br&gt;
import string&lt;br&gt;
import sys&lt;br&gt;
import os&lt;/p&gt;

&lt;p&gt;def process_log_file(filename):&lt;br&gt;
    """Counts lines and finds errors in a log file."""&lt;br&gt;
    try:&lt;br&gt;
        f = open(filename, 'r')  # Manual file handling&lt;br&gt;
        lines = f.readlines()&lt;br&gt;
        f.close()  # Don't forget to close!&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    line_count = len(lines)
    error_count = 0

    # Using the old string module for operations
    for line in lines:
        if string.find(line, 'ERROR') != -1:  # string.find instead of .find()
            error_count = error_count + 1  # Verbose increment

    print "File: %s" % filename  # Old-style string formatting
    print "Total lines: %d" % line_count
    print "Errors found: %d" % error_count
    print ""

except IOError, e:  # Old exception syntax
    print "Could not open file: %s" % str(e)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Main execution
&lt;/h1&gt;

&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == '&lt;strong&gt;main&lt;/strong&gt;':&lt;br&gt;
    if len(sys.argv) &amp;lt; 2:&lt;br&gt;
        print "Usage: python process_logs_old.py  [file2] ..."&lt;br&gt;
        sys.exit(1)&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i in range(1, len(sys.argv)):  # Manual argument iteration
    process_log_file(sys.argv[i])`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Characteristics of Early Python Code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Print Statement:&lt;/strong&gt; print was a statement, not a function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Old-Style String Formatting:&lt;/strong&gt; Using % for string interpolation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integer Division:&lt;/strong&gt; 5 / 2 returned 2, not 2.5.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;string Module:&lt;/strong&gt; Heavy use of the string module for basic operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Manual Resource Management:&lt;/strong&gt; Files were opened and closed explicitly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exception Syntax:&lt;/strong&gt; except Exception, e: instead of except Exception as e:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No List Comprehensions:&lt;/strong&gt; Initially missing this now-fundamental feature.&lt;/p&gt;

&lt;p&gt;This code gets the job done, but it feels a bit... clunky by today's standards.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 2: The Modernization Era (Python 2.5 - 3.5) - Growing Up&lt;/strong&gt;&lt;br&gt;
Python 2.5 to 2.7 introduced features that would become Pythonic staples. Then came the monumental—and controversial—leap to Python 3. This era was about cleaning up warts and adding powerful features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Example: The "Modernized" Script (circa 2010)&lt;/strong&gt;&lt;br&gt;
`# process_logs_modern.py&lt;br&gt;
import sys&lt;br&gt;
import os&lt;/p&gt;

&lt;p&gt;def process_log_file(filename):&lt;br&gt;
    """Counts lines and finds errors in a log file."""&lt;br&gt;
    try:&lt;br&gt;
        # Context manager for automatic file closing&lt;br&gt;
        with open(filename, 'r') as f:&lt;br&gt;
            lines = f.readlines()&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    line_count = len(lines)
    # Using a generator expression for memory efficiency
    error_count = sum(1 for line in lines if 'ERROR' in line)

    # New-style str.format()
    print("File: {0}".format(filename))
    print("Total lines: {0}".format(line_count))
    print("Errors found: {0}".format(error_count))
    print()

except IOError as e:  # Modern exception syntax
    print("Could not open file: {0}".format(e))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Main execution
&lt;/h1&gt;

&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == '&lt;strong&gt;main&lt;/strong&gt;':&lt;br&gt;
    if len(sys.argv) &amp;lt; 2:&lt;br&gt;
        print("Usage: python process_logs_modern.py  [file2] ...")&lt;br&gt;
        sys.exit(1)&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Simpler argument iteration
for filename in sys.argv[1:]:
    process_log_file(filename)`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Key Improvements Here:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;with Statement:&lt;/strong&gt; Automatic resource management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;print() Function:&lt;/strong&gt; Consistent with other built-ins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;New-Style String Formatting:&lt;/strong&gt; More powerful .format() method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generator Expressions:&lt;/strong&gt; Memory-efficient iterations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cleaner Exception Handling:&lt;/strong&gt; The as keyword.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cleaner Iteration:&lt;/strong&gt; Directly iterating over sys.argv[1:].&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 3: The Modern Python Powerhouse (3.6+ Today) - The AI/ML Juggernaut&lt;/strong&gt;&lt;br&gt;
Modern Python is a different beast. It's the language of choice for data scientists and AI researchers, thanks to its incredible ecosystem and new language features that make code more expressive and maintainable.&lt;/p&gt;

&lt;p&gt;Let's rewrite our script with today's features and then look at a data science example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Example: The Ultra-Modern Script (2020s)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`# process_logs_contemporary.py&lt;br&gt;
from pathlib import Path  # Modern path handling&lt;br&gt;
import sys&lt;/p&gt;

&lt;p&gt;def process_log_file(filename: str) -&amp;gt; dict:  # Type hints!&lt;br&gt;
    """Counts lines and finds errors in a log file."""&lt;br&gt;
    file_path = Path(filename)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if not file_path.exists():
    raise FileNotFoundError(f"File {filename} not found")  # f-strings!

# Read and process in one go
line_count = 0
error_count = 0

with file_path.open('r') as f:
    for line in f:
        line_count += 1
        if 'ERROR' in line:
            error_count += 1

return {  # Returning a clean dictionary
    'filename': filename,
    'line_count': line_count,
    'error_count': error_count
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;def main():&lt;br&gt;
    if len(sys.argv) &amp;lt; 2:&lt;br&gt;
        print("Usage: python process_logs_contemporary.py  [file2] ...")&lt;br&gt;
        return&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Process all files and display results
for filename in sys.argv[1:]:
    try:
        result = process_log_file(filename)
        # Using f-strings with expressions
        print(f"File: {result['filename']}")
        print(f"Total lines: {result['line_count']}")
        print(f"Errors found: {result['error_count']}")
        print()
    except Exception as e:
        print(f"Error processing {filename}: {e}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == '&lt;strong&gt;main&lt;/strong&gt;':&lt;br&gt;
    main()`&lt;/p&gt;

&lt;p&gt;But this is just scripting. Let's see where Python truly shines today.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Example: Modern Data Science &amp;amp; AI Pipeline&lt;/strong&gt;&lt;br&gt;
`# modern_ml_pipeline.py&lt;br&gt;
import pandas as pd&lt;br&gt;
import numpy as np&lt;br&gt;
from sklearn.ensemble import RandomForestClassifier&lt;br&gt;
from sklearn.model_selection import train_test_split&lt;br&gt;
from sklearn.metrics import accuracy_score&lt;br&gt;
import matplotlib.pyplot as plt&lt;/p&gt;

&lt;h1&gt;
  
  
  Modern Python features in a data science context
&lt;/h1&gt;

&lt;h1&gt;
  
  
  1. Type hints for clarity
&lt;/h1&gt;

&lt;p&gt;def prepare_data(file_path: str) -&amp;gt; tuple[np.ndarray, np.ndarray]:&lt;br&gt;
    """Load and prepare data for training."""&lt;br&gt;
    # Using pandas for data manipulation (not in stdlib, but essential)&lt;br&gt;
    df = pd.read_csv(file_path)&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Data cleaning with modern pandas&lt;br&gt;
df = df.dropna().copy()
&lt;h1&gt;
  
  
  Feature selection
&lt;/h1&gt;

&lt;p&gt;features = df[['sepal_length', 'sepal_width', 'petal_length', 'petal_width']]&lt;br&gt;
target = df['species']&lt;/p&gt;

&lt;p&gt;return features.values, target.values&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  

&lt;ol&gt;
&lt;li&gt;Using dataclasses for configuration (Python 3.7+)
&lt;/li&gt;
&lt;/ol&gt;
&lt;/h1&gt;


&lt;p&gt;from dataclasses import dataclass&lt;/p&gt;

&lt;p&gt;@dataclass&lt;br&gt;
class ModelConfig:&lt;br&gt;
    n_estimators: int = 100&lt;br&gt;
    test_size: float = 0.2&lt;br&gt;
    random_state: int = 42&lt;/p&gt;

&lt;p&gt;def main():&lt;br&gt;
    # Configuration with dataclass&lt;br&gt;
    config = ModelConfig(n_estimators=200, test_size=0.3)&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Data preparation&lt;br&gt;
X, y = prepare_data('iris.csv')
&lt;h1&gt;
  
  
  Train-test split with unpacking
&lt;/h1&gt;

&lt;p&gt;X_train, X_test, y_train, y_test = train_test_split(&lt;br&gt;
    X, y, &lt;br&gt;
    test_size=config.test_size, &lt;br&gt;
    random_state=config.random_state&lt;br&gt;
)&lt;/p&gt;
&lt;h1&gt;
  
  
  Model training - this is where Python's simplicity shines
&lt;/h1&gt;

&lt;p&gt;model = RandomForestClassifier(&lt;br&gt;
    n_estimators=config.n_estimators,&lt;br&gt;
    random_state=config.random_state&lt;br&gt;
)&lt;br&gt;
model.fit(X_train, y_train)&lt;/p&gt;
&lt;h1&gt;
  
  
  Predictions and evaluation
&lt;/h1&gt;

&lt;p&gt;predictions = model.predict(X_test)&lt;br&gt;
accuracy = accuracy_score(y_test, predictions)&lt;/p&gt;
&lt;h1&gt;
  
  
  f-string with formatting
&lt;/h1&gt;

&lt;p&gt;print(f"Model accuracy: {accuracy:.2%}")&lt;/p&gt;
&lt;h1&gt;
  
  
  Simple visualization
&lt;/h1&gt;

&lt;p&gt;plt.figure(figsize=(10, 6))&lt;br&gt;
plt.scatter(X_test[:, 0], X_test[:, 1], c=predictions)&lt;br&gt;
plt.title('Predictions Visualization')&lt;br&gt;
plt.savefig('results.png')&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  

&lt;ol&gt;
&lt;li&gt;Async/Await for modern web APIs (Python 3.5+)
&lt;/li&gt;
&lt;/ol&gt;
&lt;/h1&gt;


&lt;p&gt;import asyncio&lt;br&gt;
import aiohttp&lt;/p&gt;

&lt;p&gt;async def fetch_data(url: str) -&amp;gt; dict:&lt;br&gt;
    """Asynchronously fetch data from an API."""&lt;br&gt;
    async with aiohttp.ClientSession() as session:&lt;br&gt;
        async with session.get(url) as response:&lt;br&gt;
            return await response.json()&lt;/p&gt;

&lt;h1&gt;
  
  
  Run the async function
&lt;/h1&gt;

&lt;h1&gt;
  
  
  asyncio.run(fetch_data('&lt;a href="https://api.example.com/data')" rel="noopener noreferrer"&gt;https://api.example.com/data')&lt;/a&gt;)
&lt;/h1&gt;

&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == '&lt;strong&gt;main&lt;/strong&gt;':&lt;br&gt;
    main()`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Makes Modern Python "Modern"? The Game-Changers&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;f-strings (3.6+):&lt;/strong&gt; f"Hello {name}!" - The most loved string formatting method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Type Hints (3.5+):&lt;/strong&gt; def func(x: int) -&amp;gt; str: - Better IDE support and documentation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;pathlib (3.4+):&lt;/strong&gt; Object-oriented path handling that's cross-platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Classes (3.7+):&lt;/strong&gt; Auto-generate boilerplate for classes that are primarily data holders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Async/Await (3.5+):&lt;/strong&gt; Native support for asynchronous programming.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Walrus Operator (3.8+):&lt;/strong&gt; := for assignment expressions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structural Pattern Matching (3.10+):&lt;/strong&gt; match/case for complex conditional logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Ecosystem:&lt;/strong&gt; Libraries like NumPy, Pandas, TensorFlow, and FastAPI that build on Python's simplicity to create powerful domains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion: The Consistent Climber&lt;/strong&gt;&lt;br&gt;
Python's journey is unique. Unlike other languages that reinvented themselves, Python evolved while staying true to its core philosophy:&lt;/p&gt;

&lt;p&gt;"Readability counts." and "Simple is better than complex."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It went from:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;print statement&lt;/strong&gt; → print() &lt;strong&gt;function → f-strings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;**Manual file handling → with statements&lt;/p&gt;

&lt;p&gt;Lists and for-loops → NumPy arrays and vectorized operations&lt;/p&gt;

&lt;p&gt;CGI scripts → Django/Flask → Async with FastAPI&lt;/p&gt;

&lt;p&gt;Simple statistics → Scikit-learn → TensorFlow/PyTorch**&lt;/p&gt;

&lt;p&gt;Through careful evolution and an incredible community, Python managed to become both the best language for beginners and the preferred tool for cutting-edge AI research. That's not just growth that's a masterpiece of language design.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;What was your "wow" moment with Python? Was it discovering list comprehensions, using f-strings for the first time, or building your first machine learning model? Share your Python journey in the comments below! *&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>ai</category>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
