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.


    code for scene?

    Pythonista
    help scene module
    2
    2
    2575
    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.
    • ellie_ff1493
      ellie_ff1493 last edited by

      I'm looking for the code for the scene module, anyone knows how I can find the code for built-in modules?

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

        Many of the Pythonista-specific modules are written in C (or Objective-C) and compiled, so you can't see the source code for them. To find out if that's the case, import and look at the module in the Python console:

        >>> import console
        >>> console
        <module 'console' (built-in)>
        

        The "built-in" part means that the module is compiled and not written in Python.

        Some modules (like scene) are actually made of two modules: the main module is written in Python, and it imports a second module that is compiled. For example, you can see the location of the scene module's Python code:

        >>> import scene
        >>> scene
        <module 'scene' from '/var/containers/Bundle/Application/.../Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/scene.py'>
        

        However if you look into the scene.py file, you can see that it imports a _scene2 module, which is compiled:

        >>> import _scene2
        >>> scene2
        <module '_scene2' (built-in)>
        

        That means you can read the parts of the scene module that are written in Python (scene), but not those that are compiled (_scene2).

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