New to Python - Compiled Language?

Terry Reedy tjreedy at udel.edu
Wed Nov 5 12:32:08 EST 2003


"Relee Squirrel" <relee_s at hotmail.com> wrote in message
news:mailman.449.1067988875.702.python-list at python.org...
> Also, can Python support Linked Lists?

Linked lists are one implementation of the abstract concept List.
Extensible arrays, as in Python, are another.  The latter is more
complicated but more efficient for many (maybe most) purposes.  If you
actually need the former, you can make them with Python tuples or
lists.  Here is the basic idea:

Ltail = ('tail', None)
Lhead = ('middle', Ltail)
Lhead = ('new head', Lhead)
# use [] to be able to mutate data or link field

Now write function to walk list.  Or make LinkedList class with
__iter__ method.  Making doubly linked list is trivial modification.

For game programming, see posts in archives and PyGame site.

Terry J. Reedy






More information about the Python-list mailing list