What attributes does python import from a module? -


i checked answers this, have question attributes imported module in python.

for example, have module temp9.py:

a=10 b=20 print('a={0}, b={1}'.format(a,b)) def t9outer():      print('in imported module')     def t9inner():         print('inner function') 

then import module so: import temp9. if attributes of imported file using command:

list(filter(lambda x: not x.startswith('__'),dir(temp9))) 

i output:

['a', 'b', 't9outer'] 

my questions are

  • a , b global in scope of temp9, not across modules (as above answer says), how exported?

  • why t9inner() not imported though enclosed t9outer(), gets imported?

the answer same both questions. defined @ module level imported; not defined @ module level not imported.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -