Is there a difference between importing to / from outside the methods?

Is there a difference between the two products? Besides the volume of imports.

Either domestic or foreign imports, of
course, domestic imports would be useless if external already exist

import os

class foo(object):
    def bar(self):
        import os
        path = os.path.join('foo', 'bar')
+4
source share
2 answers

. . ( , , ), , sys.modules .

from ... import * , : Python 3.

+3

id , .

, . os global , , os bar, . , , bar - , , import os .

0

All Articles