'from X import a' versus 'import X; X.a'

后端 未结 9 2018

I\'ve seen some Python programmers use the following style fairly consistently (we\'ll call it style 1):

import some_module
# Use some_module.some_identifier in          


        
9条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-04 15:26

    You may be interested in Stack Overflow question Why does 'import x;x.y' behave different from 'from x import y', and the first one fails when package x.init is not completed?.

提交回复
热议问题