list insertion

Ross Wilson rzzzwilson at hotmail.com
Wed Aug 24 05:01:50 EDT 2005


On Tue, 23 Aug 2005 20:58:11 -0700, Randy Bush wrote:

> i am trying to insert into a singly linked list
> 
>     hold = self.next
>     self.next = DaClass(value)
>     self.next.next = hold
> 
> but i suspect (from print statement insertions) that the result
> is not as i expect.  as the concept and code should be very
> common, as i am too old for pride, i thought i would ask.
> 
> mahalo,
> randy

The example above looks like it would work, as long as other
stuff you _don't_ show is fine.  Specifically, how do you 
handle the case when the list is empty?

Better to show a more complete example with output and how that
is not what you expect.

Ross



More information about the Python-list mailing list