omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    create_obj_class ... two issues

    Pythonista
    3
    4
    2542
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JonB
      JonB last edited by

      two issues:

      1. when using on_main_thread to decorate an objc method, create_objc_class thinks there are no arguments. I think @dgelessus has pointed out the issue with wraps not being correct. Not sure if on_main_thread is needed on things that get called from the main thread anyway?

      2. the methods argument does not seem to allow instance methods. (raised an exception when adding, complaining of the extra argument, which was self). I believe the code needs to toss out the first (self) argspec.arg for methods that have an __im_func__ attribute.

      1 Reply Last reply Reply Quote 1
      • JonB
        JonB last edited by

        also, related to objc in general, a suggestion:
        please expose _get_objc_classname() in ObjCInstance's dir method, so it will be autocompleted...I can never remember the name, and it is useful!

        1 Reply Last reply Reply Quote 1
        • dgelessus
          dgelessus last edited by

          @JonB When wrapping a function with a decorator, the new (wrapper) function's arguments are normally declared as (*args, **kwargs). I'm not sure if functools.wraps fixes (or can even fix) this. Maybe the issue is really with create_objc_class not understanding varargs.

          1 Reply Last reply Reply Quote 0
          • omz
            omz last edited by

            If the method will be called on the main thread anyway, there's no need to decorate it with on_main_thread.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors