Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2447

feature request: allow namespaces to be exposed as submodules rather than classes

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Fixed
    • P4: Low
    • Some future version
    • 6.5.1
    • Shiboken
    • None
    • All
    • 07c06735e (dev)

    Description

      I have a need to expose namespace in my code as a python submodule, my C++ code is divided into several namespaces like

      namespace Framework::ModA
      /* ModA stuff */
      
      namespace Framework::ModB
      /* ModB stuff */
      

       
      Now I want to recreate such a structure in my python bindings. 

      import Framework.ModA
      import Framework.ModB
      

      currently that is not possible cause namespace is exposed as a class, the best that can be done is type alias it like:

      ModA = Framework.ModA
      
      some_func = Framework.ModA.some_func
      

      however that does not mean the same thing - as functions / variables etc arent 'available' without extra typing or having type alias everything that is inside it.

      would be nice to have an option to do so via some extra xml attr?

      <namespace-type name="decimal" asSubModule="true"> or somethng like that
      

       

      pybind11 allows something like this via def_submodule function - heres a link to github

      https://github.com/pybind/pybind11/discussions/4027

       

       

      Attachments

        For Gerrit Dashboard: PYSIDE-2447
        # Subject Branch Project Status CR V

        Activity

          People

            kleint Friedemann Kleint
            meomic Michal M
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes