How do I call the double() function?

Kushal Kumaran kushal.kumaran at gmail.com
Sat Mar 21 11:21:19 EDT 2009


On Mar 21, 7:55 pm, grocery_stocker <cdal... at gmail.com> wrote:
> Given the following....
>
> def double(val):
>     return val.bind(lambda x: val.return_(x*2))
>
> I get "AttributeError: 'int' object has no attribute 'bind' " when I
> try to do the following
>
> double(2)
>
> <snipped>

See the usage of the double function in http://lukeplant.me.uk/blogmedia/monad_explanation.py,
which is presumably where you got it from.  It's not being passed in
an ordinary int.  int's do not have bind or return_ attributes.

--
kushal



More information about the Python-list mailing list