Skip to content

Commit 1229747

Browse files
committed
add python3_same_class_different_import_path_class_id_not_same
1 parent 8e17ce0 commit 1229747

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# [python导入路径不同类id不同](2024/06/python3_same_class_different_import_path_class_id_not_same.md)
2+
3+
Python踩坑遇到同一个类在不同文件中静态变量不一样的问题 gpt说可能原因if class importing in different ways or from different paths, Python might treat them as different modules
4+
5+
原因是一个文件相对路径导入类,另一个文件从项目根目录绝对路径导入 用id函数打印了下两处文件类结果id不一样...
6+
7+
Python3没有循环依赖检测,gpt说循环依赖出现时也会同一个类多次导入出现多个id
8+
9+
公司项目代码历史遗留问题,sys.path被多个地方修改,同一个py有多种导入路径
10+
11+
还有连__init__.py也没有 同事解释说古老版本pycharm要写http://init.py才能识别包导入,现在都不用啦

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- [文章列表 - 吴翱翔的博客](/)
22
- [正在读的书](/books.md)
33
- **2024-06**
4+
- [python导入路径不同类id不同](2024/06/python3_same_class_different_import_path_class_id_not_same.md)
45
- [暗黑4评测](/2024/06/diablo4_review.md)
56
- [做市商对冲](/2024/06/market_maker_hedge.md)
67
- [NFT价格预言机](/2024/06/nft_price_oracle.md)

0 commit comments

Comments
 (0)