You want to call mytrie.items()

If "items" is bare, it's a reference to the method itself. To get the actual 
values produced by the method (the stuff you want to iterate over), you need to 
invoke the method, which in python is always done with ().

On Aug 29, 2013, at 4:38 PM, Maria McKinley <[email protected]> wrote:

> Hello,
> 
> I hope someone on this list doesn't mind answering what I think is a quick 
> question. I have been playing around with the python code found here:
> 
> http://en.wikipedia.org/wiki/Trie#A_Python_version
> 
> I can't get the iterator to work, and I wonder if I'm not calling it 
> correctly. I thought once I made my object, and added stuff to it, I could 
> just do this:
> 
> for c in mytrie.items:
>     print c
> 
> but I get this error:
> 
> TypeError: 'instancemethod' object is not iterable
> 
> What am I doing wrong?
> 
> thanks,
> Maria

Reply via email to