Re: basic class question..

2009-11-16 Thread Steven D'Aprano
On Sun, 15 Nov 2009 16:26:59 -0800, Pyrot wrote: > On 11월15일, 오후9시52분, "Diez B. Roggisch" wrote: >> Pyrot schrieb: >> >> > class rawDNA: >> >    import string [...] > (Tthe core reason that I'm bothering with this at all is because I heard > imports are costly(in time, space, processing power). I

Re: basic class question..

2009-11-15 Thread r
On Nov 15, 6:26 pm, Pyrot wrote: > 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 i

Re: basic class question..

2009-11-15 Thread Pyrot
On 11월15일, 오후9시52분, "Diez B. Roggisch" 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__(s

Re: basic class question..

2009-11-15 Thread Pyrot
On 11월15일, 오후10시15분, Tim Chase wrote: > Pyrot wrote: > > class rawDNA: > >import string > >trans = string.maketrans("GATC","CTAG") > > >def __init__(self, template = "GATTACA"): > >self.template = template //shouldn't this make "template" > > accessible within the scope of

Re: basic class question..

2009-11-15 Thread Diez B. Roggisch
Diez B. Roggisch schrieb: 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"): s

Re: basic class question..

2009-11-15 Thread Tim Chase
Pyrot wrote: class rawDNA: import string 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. Python's scope resolutio

Re: basic class question..

2009-11-15 Thread Diez B. Roggisch
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.tem

basic class question..

2009-11-15 Thread Pyrot
class rawDNA: import string trans = string.maketrans("GATC","CTAG") def __init__(self, template = "GATTACA"): self.template = template //shouldn't this make "template" accessible within the scope of "rawDNA"?? def noncoding(self):