the deceptive continuous assignments
Chris Angelico
rosuav at gmail.com
Tue Dec 6 07:33:26 EST 2011
On Tue, Dec 6, 2011 at 11:20 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> You found an unsafe overlap.
> x.thing = x = 1
> would work, though it seems strange (and unlikely in practice) to rebind x
> to an int after it is bound to a class k instance.
This code is starting to look like it wants to work with a linked list.
>>> class node:
def __init__(self,x):
self.payload=x
self.next=None
def walk(self):
print("My payload is: "+self.payload)
if self.next: self.next.walk()
>>> head=tail=node("This")
>>> tail.next=tail=node("is")
>>> tail.next=tail=node("a")
>>> tail.next=tail=node("test.")
>>> head.walk()
My payload is: This
My payload is: is
My payload is: a
My payload is: test.
>>>
ChrisA
More information about the Python-list
mailing list