Newbie question - calling external Python programs
Manuel Gutierrez Algaba
thor at localhost.localdomain
Sat Aug 19 18:36:49 EDT 2000
On Sat, <stephen_ferg at worldnet.att.net> wrote:
[...about imports. Civilised ways of importing lot of modules...]
Well, python is so damned advanced that you can import a module
whenever you want to. You can import :
- inside a function:
def a():
import cool_module
cool_module.init_yourself()
- inside any class method
python is so damned flexible that 99 % of your code may be broken
and the process doesn't stop if it never reaches to the "buggy zones".
Even you can safely recover from faulty imports.
try:
import a
except:
flag_faulty_import_a = 1
Although is not mentioned anywhere. Python is a dictionary-oriented
language or better, a symbols-table-oriented language.
You can add new symbols to the "current" symbols-table whenever
you want and you never have problems if all names (of functions/
variables) have been found in the symbols-table.
Doing the similar thing in C++ or Java is , how would I say?,
f*ckingly impossible.
---
MGA
More information about the Python-list
mailing list