text: Q:
  
  Defining a function with string.replace within a class
  
  I have defined a class "DNA". I am now trying to create a function within that class that will allow me to translate DNA to RNA (which bascially means replacing any "T" with "U"). My DNA class has inherited parameters from another class.
  I have to use the string.replace method.
  class DNA(Seq):
     def __init__(self, seq):
      Seq.__init__(self, seq, pattern=(re.compile('[^ACGTacgt]')))
      self.data = seq.upper()
  def __repr__(self):
          return self.data
  
  I want to use the function on a dna-sequence of the DNA class.
  Edit:
  I want to be able to do the following:
  dna1 = DNA('ACCCGT')
  rna1 = dna1.translate_to_RNA()
  print rna1
  
  Where the translate_to_RNA() is my defined function and the output would be ('ACCCGU')
  Edit2: 
  class Seq:
      def __init__(self, seq, pattern): 
          if pattern.search(seq): 
              print " Warning : sequence contains illegal characters " 
          self.data = seq.upper() 
      def __getitem__(self, index):
          return self.data[index]
      def __len__(self):  
          return len(self.data) 
  
  import re
  
  class DNA(Seq):
      def __init__(self, seq):
          Seq.__init__(self, seq, pattern=(re.compile('[^ACGTacgt]')))
          self.data = seq.upper()
          self.seq = seq
      def __repr__(self):
          return self.data
      def translate_to_RNA(self):
          new_string = self.seq("T","U")
          rna1 = RNA(new_string)
          return rna1
  
  class RNA(Seq):
      def __init__(self, seq):
          Seq.__init__(self, seq, pattern=(re.compile('[^ACGUacgu]')))
          self.data = seq.upper()
      def __repr__(self):
              return self.data
  
  A:
  
  Define a method within you use the string.replace() method on the string that represents the data. (You didn't explain how this data was represented).
  Edition:
  You should use a string variable in the DNA class that will save the string you initialize the DNA instance with. you should define a similar RNA class.
  then, you can implement a function in the DNA class like this:
  def translate(self):
      new_string=self.string_representation.replace("T","U")
      rna1 = RNA(new_string)
      return rna1
  
  as for the print operator, you need to implement a string cast for you RNA class. (using str)
  
  