Creating Classes

seafoid fitzpadj at tcd.ie
Fri Dec 18 14:21:14 EST 2009


Hey Guys,

I have started to read over classes as a brief respite from my parsing
problem.

When a class is defined, how does the class access the data upon which the
class should act?

Example:

class Seq:                                                                

    def __init__(self, data, alphabet = Alphabet.generic_alphabet):
        self.data = data 
        self.alphabet = alphabet

    def tostring(self):                                                   
        return self.data                                                  

    def tomutable(self):
        return MutableSeq(self.data, self.alphabet)
    
    def count(self, item):
        return len([x for x in self.data if x == item])

I know what it should do, but have no idea how to feed it the data.

Methinks I need to invest in actual computing books as learning from
biologists is hazy!

Kind regards,
Seafoid.
	      
-- 
View this message in context: http://old.nabble.com/Creating-Classes-tp26848375p26848375.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list