Code Maintenance & Programming Rules

 This guide outlines essential best practices spanning code style, architectural design, debugging, testing, performance, and portability—all aimed at reducing the long-term cognitive load of code maintenance. 🎨 1. Style Code is written for humans to read, and only incidentally for computers to execute. Variable Naming : Use descriptive names for global variables, and short names for local variables. Precision and Consistency : Use active names for functions (e.g., calculateTotal ). Above all, keep your coding style consistent throughout the project. Structure & Expressions : Use a consistent indentation and brace ( {} ) style to show program structure visually. Use the natural form for expressions. Use parentheses to make the semantics unambiguous. Break up overly complex expressions to keep them clear. Side Effects & Macros : Beware of functions with side effects. Avoid function-like macros; if unavoidable, parenthesize the macro body and arguments carefully. Magic Numbe...

打造自己的 Python 直譯器

若您覺得文章寫得不錯,請點選網誌上的廣告,來支持小編,謝謝。

此篇文章要說明如何在 Lubuntu 20.04 編譯自己的 Python Interpreter,使用的 Python Source Code Version 為 3.9.0a6。

步驟一:更新 Lubuntu 系統
sudo apt-get update

步驟二:安裝編譯程式庫
sudo apt-get install -y build-essential checkinstall 
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev /
tk-dev libgdbm-dev libc6-dev libbz2-dev

步驟三:下載 Python 原始碼
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0a6.tgz

步驟四:解壓縮
sudo tar xzf Python-3.9.0a6.tgz

步驟五:設定編譯參數
sudo ./configure --enable-optimizations

步驟六:編譯並安裝
sudo make altinstall


步驟七:確認 Python 版本
python3.9 -V

步驟八:測試 Python 直譯器
建立 hello.py 檔案,內容如下:
print("這是Python")

這個網誌中的熱門文章