On Mar 22, 1:55 am, grocery_stocker <cdal...@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) > > Below is the output... > > [cdal...@localhost ~]$ python > Python 2.4.3 (#1, Oct 1 2006, 18:00:19) > [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> def > double(val): > > ... return val.bind(lambda x: val.return_(x*2)) > ...>>> double(2) > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "<stdin>", line 2, in double > AttributeError: 'int' object has no attribute 'bind'
How you call it is irrelevant; you already achieved that. The problem is that your double() function is weird. ... it fails (quite justifiably) trying to execute 2.bind(). Just as well, because the next problem would be 2.return_() ... int objects just don't have such methods (as the error message pointed out). Presumably you are trying to achieve a goal that's a bit more useful than def double(val): return val * 2 so perhaps you could explain what that goal is and someone may be able to help. -- http://mail.python.org/mailman/listinfo/python-list