Is there a point to import the same module in two different ways in a program?

后端 未结 4 1176
礼貌的吻别
礼貌的吻别 2021-01-23 00:19

Is there a point to import as both wildcard and non-wildcard manner like:

import spam as sp
from spam import *

in the very same file?<

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-23 00:50

    The only reason that I could think is that you want to change from from spam import * to import spam as sp. If you would just replace those lines, it would instantly break the code, you would have to prefix everything with sp.. If you want to do this change at a slower pace, you can do this. Then you can slowely add the sp. where needed and eventually remove the from spam import *.

提交回复
热议问题