On 11월15일, 오후9시52분, "Diez B. Roggisch" <de...@nospam.web.de> wrote: > Pyrot schrieb: > > > class rawDNA: > > import string > > Importing here is unusual. Unless you have good reasons to do so, I > suggest you put the imports on top of the file. > > > trans = string.maketrans("GATC","CTAG") > > > def __init__(self, template = "GATTACA"): > > self.template = template //shouldn't this make "template" > > accessible within the scope of "rawDNA"?? > > No. > > > > > def noncoding(self): > > print template.translate(trans) // > > This needs to be > > print self.template.translate(trans) > > Thes scopes insied a class are only the method-locals (to which the > parameters count of course), and globals. > > Diez
Thanks for the tip Diez. (Tthe core reason that I'm bothering with this at all is because I heard imports are costly(in time, space, processing power). If this turns out to be a non-issue, than my questions regarding Imports are all moot :->) I forgot to write about my second question which was: what happens when I use the import statement within a class/function declaration? I'm thinking either 1) It imports during the class/function declaration 2) It imports the first time a class/function call(x = rawDNA() ) occurs But if it's 2) then is the import valid outside of the function/class? what happens when the last function reference is removed?(del x) obviously this is a lot of questions... I respect your(or anyone who would like to help me) time, so all I ask is some kind of document or "Best practices" guide dealing all about "import".(because sadly, http://docs.python.org/reference/simple_stmts.html#the-import-statement does not ask my questions) -- http://mail.python.org/mailman/listinfo/python-list