You're returning a mutable object from methodB. You should either return 
an immutable object (such as a tuple or a string), or return a *copy* of 
your mutable object.

some_list.reverse() reverses the list in-place. That's why you're seeing 
the strange reversal results you report.

The easiest way to achieve this is to change methodA as below:

>     def methodA(self):
>         "doc string"
>         objects = self.methodB(self)
>       objects.reverse()
>       attrib = ''     
>       for object in objects:
>               attrib = attrib + 'some html'
>       return attrib

def methodA(self):
  "doc string"
  objects = self.methodB(self)[:]

Here, you're making a copy of what methodB returns, before doing stuff to it.

Otherwise, you can re-reverse what methodB returns using try: finally: in methodA.

If methodB is called by anything else, as methodB is recursive, you should either make 
it non-recursive, or access it via a methodC:

def methodC(self, object):
  return self.methodB(object)[:]

Steve Alexander
Software Engineer
Cat-Box limited

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to