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.


    How to import a bunch of functions I typed from within pythonista into another script

    Pythonista
    2
    5
    2487
    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.
    • Raph
      Raph last edited by

      Sorry if the question is very basic. Maybe I overlooked something in the documentation.I tried
      import filename

      With no luck, whether the filename was x or x.py does not change a thing.

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

        'import' works propely in my enviroment.

        a.py

          def afunc():
            print 'afunc called'
        

        b.py

          import a
          a.afunc()
        

        Run b.py.
        It'll work.

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

          When I try to run b.py, the interpretor stops at "import a" and gives that as an error message:

          ImportError: No module named a

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

            Probabily your "a.py" may be "a.py.py"
            If so, Delete ".py" extension.
            Pythonista automatically add .py extension to its filename.

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

              Yes that did it! Thanks alot. The strange thing is that I tried that before, but I guess at that time the file I wished to import was still in a sub-folder.

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