[Pyobjc-dev] @python_method rationale?
Brought to you by:
ronaldoussoren
From: Just v. R. <jus...@gm...> - 2018-03-11 07:42:44
|
Hi, I’m curious about the rationale of the @python_method decorator from the objc module. In current PyObjC versions any method in an NSObject subclass that does not conform to the ObjC conventions need to be decorated with @python_method. I understand this means such methods can’t be called from ObjC. The thing is, when I’m writing Python code, I am well aware of what will be a valid ObjC method and what won’t be. I write lots of methods that I know will never be accessed from the ObjC side, and I’m fine with that. I want to write Pythonic code, so I have no interest in using ObjC selector naming conventions for such methods. Yet my code is now necessarily littered with @python_method decorators, which feels clumsy and ugly, and goes against the point of wanting to write clean Python code that does _not_ use the ObjC naming conventions. I’m currently looking at a page of code containing seven methods, _all_ of which have the decorator, which makes me sad :) I long for the “old” days when these things “just worked”, and there was simple and clean code on the Python side. If I omit the decorator, an exception is raised: objc.BadPrototypeError. So PyObjC already knows that that method is not conforming. I feel this is a case of “explicit is better than implicit” going too far. Maybe I’m missing something, but how is the @python_method decorator actually solving problems? So far it’s only gettin in my way. Thanks for any insights, Just |