Jul-29-2017, 03:15 AM
suppose you have a some functions in a module and two of these functions need to call the other functions. you need to call those two functions in a script.
an example module (named callers.py) to test this concept:
an example module (named callers.py) to test this concept:
from __future__ import division, print_function def a(): print('this is a') return def b(): print('this is b') return def c(): print('this is c') return def d(): print('this is d') return def x(): print('this is x') a() b() return def y(): print('this is y') c() d() returnan example script that uses this:
from __future__ import division, print_function from callers import x, y x() print('foobar') y()if you run this example script with this example module, the expected output is:
Output:this is x
this is a
this is b
foobar
this is y
this is c
this is d
my question is: how are functions a,b,c, and d referenced if only x and y are imported. i do understand (because i read it somewhere) that when "from somemodule import ..." is used, the whole module gets imported somewhere and the particular names being used are inserted into the importer script. how do x and y find a,b,c, and d? where are the names placed?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.