from … import OR import … as for modules

后端 未结 6 453
萌比男神i
萌比男神i 2020-11-29 02:57

Should I use

from foo import bar

OR

import foo.bar as bar

when importing a module and an

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 03:23

    The only thing I can see for the second option is that you will need as many lines as things you want to import. For example :

    import foo.bar as bar
    import foo.tar as tar
    import foo.zar as zar
    

    Instead of simply doing :

    from foo import bar, tar, zar
    

提交回复
热议问题