[Python-Dev] Getting rid of unbound methods: patch available
Noam Raphael
noamraph at gmail.com
Fri Jan 21 08:59:47 CET 2005
> > and is more consistent with the general convention, that running
> > A = B
> > causes
> > A == B
> > to be true. Currently, Class.func = staticmethod(func), and Class.func
> > = func, don't behave by this rule. If the suggestions are accepted,
> > both will.
>
> Well, given that attribute assignment can be overloaded, you can't
> depend on that requirement all the time.
>
Yes, I know. For example, I don't know how you can make this work for
classmethods. (although I have the idea that if nested scopes were
including classes, and there was a way to assign names to a different
scope, then there would be no need for them. But I have no idea how
this can be done, so never mind.)
I just think of it as a very common convention, and I don't find the
exceptions "aesthetically pleasing". But of course, I accept practical
reasons for not making it that way.
> I recommend that you work around it by setting the default to None and
> substituting the real default in the function.
That's a good idea, I will probably use it. (I thought of a different
way: don't use decorators, and wrap the function in a staticmethod
after defining the function that uses it. But this is really ugly.)
Thanks for your reply,
Noam
More information about the Python-Dev
mailing list