[Chicago] AttributeError on implementation of high order functions

Brian Curtin brian at python.org
Tue Nov 6 04:16:52 CET 2012


On Mon, Nov 5, 2012 at 7:42 PM, Raghavan <itsrag at gmail.com> wrote:
> I am trying to implement a mapstream
> class MapStream(Stream):
>     def __init__(self, fn, stream):
>         super(MapStream, self).__init__()
>         self.fn = fn
>         self.stream = stream
>
>     def popNext(self):
>         val = self.stream.popNext()
>         return self.fn(val)
>
>     def popN(self,num_N):
>         n_poped_list = ()
>         while num_N:
>           n_poped_list.add(self.popNext()) #Error line
>             num_N -= 1
>         return n_poped_list
>
>
> The popN function is throwing an error stating "AttributeError: 'tuple'
> object has no attribute 'append'" in the underlined line above.
>
> Please help me out to figure out this issue.

Although Carl already answered, make sure you put accurate error
messages in your questions. That error message couldn't have come from
that code.


More information about the Chicago mailing list