On Mon, Oct 1, 2012 at 3:29 AM, Claudia Millán Nebot
I've just started to look into the cctbx facilities, and as i'm a newbie in both object oriented programming and in general to the system, i'm tryng to play around and find by myself how things are working. Using the cctbx.python, i realised that it is necessary to import explicitly the module amino_acid_codes, while for others like atom_name_interpretation this is done straigthforward if you do an import from a lower level (like from iotbx.pdb import *). Is there some good reason because this has to be like that?
I suspect this is a Python quirk - atom_name_interpretation is imported at the top of iotbx/pdb/__init__.py, amino_acid_codes is not. In general, however, I would recommend two rules for dealing with imports: 1. Always explicitly import any module you want - with the exception that if you do this: import iotbx.pdb.amino_acid_codes you will also have access to iotbx.pdb as well. In this case you might want to do this: from iotbx.pdb import amino_acid_codes, atom_name_interpretation the choice of when to use "from foo import bar" versus "import foo.bar" is up to you, but the latter is a better idea if there is any ambiguity in the names of submodules (for instance, anything named "utils", of which there are probably a half-dozen). 2. Never use "from foo import *" - it's just a bad idea, because anyone else looking at the code won't be able to tell where a function comes from. (Actually, we use this frequently for Boost.Python extensions, but we shouldn't.) -Nat