Image

Imagef_lynx wrote in Imagepython_dev

Bug or Feature?

let us consider the following example:
---cut---
class method(object):
	def __call__(self, *p, **n):
		# do something useful...
		return None

class SomeClass(object):
	def real_method(self):
		return None
	fake_method = method()

some_object = SomeClass()

some_object.another_fake_method = lambda: 1

--uncut--


now, the thing is that the only entity that is going to act as a method
is the "real_method" (e.g. get wrapped with an instancemethod on access
with all the associated consequences... etc.).

while it might be logical for the "another_fake_method" to act as a
function (as it might also be be logical the other way around,
a-la Self) but the "fake_method" also does not get wrapped (due to the
fact that it is not a function), but in terms of functionality and
usecases it does not differ from a function in no significant way! thus
should behave the same in all situations.... (IMHO)

the most significant problem is that the "fake_method" does not get a
reference to the object it was called from (behaves as a static method),
though there are ways to explicitly pass self to such methods, all of
them look and feel hackish...

thus, the question is: is this a "theoretically" correct behavior, and
should one avoid such cases?