Reference to list element question

David R. Favor dfavor at austin.ibm.com
Wed Feb 16 14:05:47 EST 2000


The following code attempts to create a reference to a
list element to reduce overhead for large files, however
the result is a copy operation.

How does one create a pointer, or reference, to a list
element, such that the list element data may be operated
upon via the pointer (reference)?

Thanks.

_______


def chomp(lines):

   "remove the end of line markers from array"

   i = 0
   while i < len(lines):

      # this works improperly, because it's not a reference?
      line = lines[i]

      if line[-1] == '\n':
         line = line[:-1]

      i = i + 1




More information about the Python-list mailing list