Objects in Python

Chris Angelico rosuav at gmail.com
Wed Aug 22 11:47:46 EDT 2012


On Thu, Aug 23, 2012 at 1:25 AM, shaun <shaun.wiseman91 at gmail.com> wrote:
>         def breakuparray(self):
>                 for row in self.array:
>                         mer = row[0].ljust(25, ' ')
>                         merc = row[1].ljust(13, ' ')
>                         mertype = row[2]
>                         merloc = row[3]
>                         mercount = row[4]
>                         mersec = row[5]
>                         acq = row[6]

The "for ... in ..." construct is a loop. I'm not sure what you're
trying to accomplish here, but you're taking the last entry in
self.array and unpacking that as a nested array. Perhaps not what you
had in mind.

For what you're doing there, though, a class is overkill. Remember,
Python isn't Java; the most natural way to do everything isn't
necessarily to write a class that unpacks things and packs them up
again in a different way.

ChrisA



More information about the Python-list mailing list