Skip to content

Commit

Permalink
add python3_same_class_different_import_path_class_id_not_same
Browse files Browse the repository at this point in the history
  • Loading branch information
pymongo committed Jun 18, 2024
1 parent 8e17ce0 commit 1229747
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# [python导入路径不同类id不同](2024/06/python3_same_class_different_import_path_class_id_not_same.md)

Python踩坑遇到同一个类在不同文件中静态变量不一样的问题 gpt说可能原因if class importing in different ways or from different paths, Python might treat them as different modules

原因是一个文件相对路径导入类,另一个文件从项目根目录绝对路径导入 用id函数打印了下两处文件类结果id不一样...

Python3没有循环依赖检测,gpt说循环依赖出现时也会同一个类多次导入出现多个id

公司项目代码历史遗留问题,sys.path被多个地方修改,同一个py有多种导入路径

还有连__init__.py也没有 同事解释说古老版本pycharm要写http://init.py才能识别包导入,现在都不用啦
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- [文章列表 - 吴翱翔的博客](/)
- [正在读的书](/books.md)
- **2024-06**
- [python导入路径不同类id不同](2024/06/python3_same_class_different_import_path_class_id_not_same.md)
- [暗黑4评测](/2024/06/diablo4_review.md)
- [做市商对冲](/2024/06/market_maker_hedge.md)
- [NFT价格预言机](/2024/06/nft_price_oracle.md)
Expand Down

0 comments on commit 1229747

Please sign in to comment.