Python - import in if

后端 未结 4 1807
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-15 16:18

I wrote little wrapper for urllib (python3). Is it proper and safe to import module in if?

if self.response_encodi         


        
4条回答
  •  一整个雨季
    2020-12-15 16:50

    Sure, that's fine. It can even be necessary in cases where the module has initialization code that you don't always want to run.

提交回复
热议问题