[Tutor] Copying a list?
Lloyd Kvam
pythontutor at venix.com
Wed Aug 27 19:37:01 EDT 2003
That looks OK to me. Bob's suggestion of b = a[:] avoids importing
the copy module. This is good, so long as you're comfortable using
slice notation to signify a copy. Personally, I would not use list(a)
to get a copy simply because it looks more like a transformation (e.g.
turning a tuple into a list).
(I keep my pythontutor email folder sorted by thread. When someone
simply repliese to another email - even if they change the subject,
the email gets added to the original thread. I assume that this
would also apply to the mail-list archives. It's better to start
a new thread with a new message. Add tutor at python.org to your address
book if you have to.)
Zak Arntson wrote:
> import copy
>
> class AppObject:
>
> def handle(self, event):
> event_children = copy.copy(self.children)
> event_children.reverse()
>
> for child in event_children:
> child.handle(event)
>
> self._handle(event)
> ###
>
> Does that make sense?
>
> ---
> Zak Arntson
> www.harlekin-maus.com - Games - Lots of 'em
>
--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358
voice: 603-443-6155
fax: 801-459-9582
More information about the Tutor
mailing list