Re: [Pyobjc-dev] @python_method rationale?
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2018-03-15 17:58:32
|
The change is intentional and makes it possible to to write nicer code without running into vague issues. I fixed a number of bugs in my code when I made PyObjC more strict and started requiring the use of @python_method when writing (basically) PEP8-style method names. In hindsight it would have been better to have required explicit marking of methods that need to be called from Objective-C, but that’s not something I can change at this point. Ronald > On 11 Mar 2018, at 08:42, Just van Rossum <jus...@gm...> wrote: > > 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 > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |