@@ -191,7 +191,52 @@ Python不是一个封闭的体系,是一个开放系统。开放系统的最
191191##模块中的'__ all__ '
192192
193193上面的模块虽然比较简单,但是已经显示了编写模块和在程序中导入模块的基本方式。在实践中,所编写的模块也许更复杂一点,比如,我写了这么一个模块,并把其文件命名为21901.py
194- http://python.jobbole.com/81187/
194+ http://python.jobbole.com/81187/mZ
195+ >>> import sys
196+ >>> sys.path.append("~ /Documents/StarterLearningPython/2code/pp.py")
197+ >>> import pp
198+ >>> pp.public_variable
199+ 'Hello, I am a public variable.'
200+ >>> pp._ private_variable
201+ 'Hi, I am a private variable.'
202+ >>> from pp import *
203+ >>> _ private_variable
204+ Traceback (most recent call last):
205+ File "<stdin >", line 1, in <module >
206+ NameError: name '_ private_variable' is not defined
207+ >>> public_variable
208+ 'Hello, I am a public variable.'
209+ >>> public_teacher()
210+ I am a public teacher, I am from JP.
211+ >>> _ private_teacher()
212+ Traceback (most recent call last):
213+ File "<stdin >", line 1, in <module >
214+ NameError: name '_ private_teacher' is not defined
215+ >>> import pp
216+ >>> pp.public_teacher()
217+ I am a public teacher, I am from JP.
218+ >>> pp._ private_teacher()
219+ I am a private teacher, I am from CN.
220+
221+ >>> import sys
222+ >>> sys.path.append("~ /Documents/StarterLearningPython/2code/pp.py")
223+ >>> from pp import *
224+ >>> dir(pp)
225+ Traceback (most recent call last):
226+ File "<stdin >", line 1, in <module >
227+ NameError: name 'pp' is not defined
228+ >>> public_variable
229+ Traceback (most recent call last):
230+ File "<stdin >", line 1, in <module >
231+ NameError: name 'public_variable' is not defined
232+ >>> _ private_variable
233+ 'Hi, I am a private variable.'
234+ >>> public_teacher()
235+ I am a public teacher, I am from JP.
236+ >>> _ private_teacher()
237+ Traceback (most recent call last):
238+ File "<stdin >", line 1, in <module >
239+ NameError: name '_ private_teacher' is not defined
195240
196241
197242##` __init__.py ` 方法
@@ -202,4 +247,4 @@ http://python.jobbole.com/81187/
202247
203248[ 总目录] ( ./index.md )   ;  ;  ; |  ;  ;  ; [ 上节:错误和异常(3)] ( ./218.md )   ;  ;  ; |  ;  ;  ; [ 下节:标准库(1)] ( ./220.md )
204249
205- 如果你认为有必要打赏我,请通过支付宝:** qiwsir@126.com ** ,不胜感激。
250+ 如果你认为有必要打赏我,请通过支付宝:** qiwsir@126.com ** ,不胜感激。
0 commit comments