Newbie questions part 2, thanks
David Grenier
grenieda at hotmail.com
Thu Nov 15 13:19:55 EST 2001
> >
> > Whenever I call cons.mappe(lambda x:2*x, cons(1,[]))
>
> When you call cons.mappe(x,y), the method actually gets called
> with 3 args. The first is bound to cons itself. Normally
> you define a method like this:
> def methodname(self, arg1, arg2): ...
Now I tried to declare the method this way and it didn't work. I get exactly
the same error. But I understand the problem is around that. I still can't
figure out how to do it. You see I had another method, append(schemelist1,
schemelist2) it worked well even without self as the first argument, and I
assume it worked because schemelist1 was of type cons. Have any idea?
> Also you can rewrite
>
> > if type(schemelist.cdr) is InstanceType and
schemelist.cdr.__class__==cons:
>
> as
> if isinstance(schemelist.cdr, cons):
>
Do you mean that if isinstance(schemelist.cdr, cons) would do both the job
of type(schemelist.cdr) is InstanceType and schemlist.cdr.__class__=cons...
still that makes sense... I'll try it out... it'll unload the code a bit.
More information about the Python-list
mailing list