Giter Site home page Giter Site logo

importit's Introduction

banner

importit

importit downloads badge importit version badge importit python versions badge

Import python code from anywhere.

importit is a python code import helper. Using it, you can dynamically import python code from different sources (like gists, python files on the internet, local python files). You don't need to copy python code snippets from project to project.

Some of use cases can be:

  • Reusing python code snippets in multiple places and projects
  • Dynamically reloading python code on live environments
  • You tell me, what will you use it for?

How to install?

pip install importit

From where do you want to import?

Github Gist

Find the gist id from the gist url: https://gist.github.com/<username>/<gist id>

Using this gist as an exmaple:

from importit import import_gist

imported_gist = import_gist("imported_gist", "51dcf067f4e445c3f837d26efd2c138e")

imported_gist.first_file.some_function()
imported_gist.second_file.some_other_function()

Note: The gist will be imported in the form of module, with each python file in the gist as a submodule.

Remote File

Use any valid python file url (for example, http://bit.ly/aPythonFile)

from importit import import_remote_file

imported_file = import_remote_file("imported_file", "http://bit.ly/aPythonFile")

imported_file.some_function()

Local File

from importit import import_remote_file

imported_file = import_remote_file("imported_file", "/home/divykj/aPythonFile.py")

imported_file.some_function()

Code Snippet

from importit import import_code

python_code = """
def some_function():
    # do some crazy things
    pass
"""

imported_code = import_code("imported_code", python_code)
imported_code.some_function()

Planning to add Github, Gitlab, Bitbucket (and other git repository services) and maybe PyPI support soon.


Want to contribute?

To get more information on contributing, go to the CONTRIBUTING.md.

Also read the CODE_OF_CONDUCT.md.

importit's People

Contributors

dvjn avatar scorphus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

scorphus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.