"""Offline Python verification lab for PyCharm Chapter 02 (intro)."""
import json
VERSION = "CPython 3.12.14 offline PyCharm workflow verifier (desktop IDE not launched)"
def case_ide_comparison_matrix():
matrix = {
"智能代码补全": {"PyCharm": "支持", "VS Code": "支持(需插件)", "Jupyter Notebook": "不支持", "Spyder": "支持"},
"调试工具": {"PyCharm": "内置", "VS Code": "支持(需插件)", "Jupyter Notebook": "不支持", "Spyder": "内置"},
"版本控制集成": {"PyCharm": "内置", "VS Code": "支持(需插件)", "Jupyter Notebook": "不支持", "Spyder": "不支持"},
"科学计算支持": {"PyCharm": "支持", "VS Code": "支持(需插件)", "Jupyter Notebook": "支持", "Spyder": "支持"},
"Web 开发支持": {"PyCharm": "支持", "VS Code": "支持(需插件)", "Jupyter Notebook": "不支持", "Spyder": "不支持"},
"跨平台支持": {"PyCharm": "支持", "VS Code": "支持", "Jupyter Notebook": "支持", "Spyder": "支持"},
"免费版本": {"PyCharm": "社区版", "VS Code": "免费", "Jupyter Notebook": "免费", "Spyder": "免费"},
}
pycharm_builtin_count = sum(1 for row in matrix.values() if row["PyCharm"] in ("支持", "内置"))
vscode_plugin_dependent = sum(1 for row in matrix.values() if "插件" in row["VS Code"])
expected = {
"row_count": 7,
"ide_count": 4,
"pycharm_native_features": 6,
"vscode_plugin_dependent": 5,
"all_cross_platform": True,
}
actual = {
"row_count": len(matrix),
"ide_count": len(next(iter(matrix.values()))),
"pycharm_native_features": pycharm_builtin_count,
"vscode_plugin_dependent": vscode_plugin_dependent,
"all_cross_platform": all(v == "支持" for v in matrix["跨平台支持"].values()),
}
return {
"name": "ide_comparison_matrix",
"summary": "核对 PyCharm 与 VS Code、Jupyter Notebook、Spyder 的 7 维度能力矩阵",
"expected": expected,
"actual": actual,
"passed": actual == expected,
}
def case_ecosystem_and_scenario_mapping():
scenarios = {
"web": ["Django", "Flask", "FastAPI"],
"data_science_ml": ["Jupyter", "Conda", "PyTorch", "TensorFlow", "Hugging Face"],
"engineering": ["Python", "Database", "Git"],
"automation_education": ["Debugger", "UnitTest", "InteractiveUI"],
}
expected = {
"scenario_groups": 4,
"web_frameworks": 3,
"ml_stack_count": 5,
"has_fastapi_and_hf": True,
}
actual = {
"scenario_groups": len(scenarios),
"web_frameworks": len(scenarios["web"]),
"ml_stack_count": len(scenarios["data_science_ml"]),
"has_fastapi_and_hf": "FastAPI" in scenarios["web"] and "Hugging Face" in scenarios["data_science_ml"],
}
return {
"name": "ecosystem_and_scenario_mapping",
"summary": "验证 PyCharm 在 Web 开发、数据科学与机器学习、数据库/Git 及教学脚本四类场景的生态覆盖",
"expected": expected,
"actual": actual,
"passed": actual == expected,
}
def case_edition_unification_model():
editions = {
"community_legacy": {"free": True, "open_source": True, "web_db_pro": False},
"professional_legacy": {"free": False, "open_source": False, "web_db_pro": True},
"unified": {"free_core": True, "optional_pro_subscription": True, "single_installer": True},
}
expected = {
"community_free": True,
"pro_has_web_db": True,
"unified_single_installer": True,
}
actual = {
"community_free": editions["community_legacy"]["free"],
"pro_has_web_db": editions["professional_legacy"]["web_db_pro"],
"unified_single_installer": editions["unified"]["single_installer"],
}
return {
"name": "edition_unification_model",
"summary": "校验社区版、专业版与统一版的功能边界与授权模型",
"expected": expected,
"actual": actual,
"passed": actual == expected,
}
def main():
cases = [
case_ide_comparison_matrix(),
case_ecosystem_and_scenario_mapping(),
case_edition_unification_model(),
]
print(json.dumps({"version": VERSION, "cases": cases}, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()
本例需在 Windows x64、CPython 3.12.14 离线 PyCharm 工程语义与配置验证器(未启动桌面端 PyCharm IDE)。 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:Windows x64、CPython 3.12.14 离线 PyCharm 工程语义与配置验证器(未启动桌面端 PyCharm IDE)。
入口文件:projects/pycharm-intro-lab/explore-intro.py
本地运行步骤快速上手
- 点击上方“保存源码”保存为
explore-intro.py,或下载右侧课程工程包。 - 确认本地已准备 Windows x64、CPython 3.12.14 离线 PyCharm 工程语义与配置验证器(未启动桌面端 PyCharm IDE)。。
- 按对应章节命令执行,结合正文核对实际输出。
附件与关联工程包下载
课程关联工程包(登记关联17章) · 含当前章节或实例 · mbskycom202612a2240.zip
课程关联工程包(登记关联1章) · 含当前章节或实例 · mbskycom202612a2248.zip