Usefulness of Custom Module / Replit DB

Two newbie questions:

  1. How do I import a custom python module that I created in a replit into another replit. I’m sure there must be a way.
  2. What is the usefulness of the Replit DB? Data I entered while in one replit does not appear in another one of my replits. Perhaps I’m doing something wrong.
    Thank you

Since this is python, you could make it a package and upload it to PyPi.

It’s per-repl storage, if you want multiple repls to share it, you would need a database proxy.

1 Like

If you don’t have a PyPI account, you can do the following:

File structure

main.py
module.py

In main.py:

import module

Or if the module is in a package:

main.py
package/
  __init__.py
  module.py

This will import the contents of package/__init__.py:

import package

And this will import the contents of package/module.py:

import package.module

In package/__init__.py, you can import package/module.py like this:

import .module

or:

from .module import *

You can find a database proxy here.

1 Like

They said their code was in a different repl, so this would not work in their program’s current state.

Oh right yes I forgot

@johnm92008 You can make your “different Repl” a template and fork that template.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.