Import python functions from anywhere!
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Import From (Anywhere)


This module allows you to import python functions from anywhere!

It's early days. Help out by submitting a pull request.

Currently supported hosts:

  • Twitter
  • Pastebin
  • Gist
  • DNS TXT Records

(Disclaimer: This is not a serious project, just a bit of fun.)


~ >> pip install importfrom


~ >> python -m pip install importfrom


First of all, you have to upload the code.

For example:

def hello(name):
    return 'Hello, %s!' % name

def bye(name):
    return 'Bye, %s!' % name

Then, you can import and use it as normal:

# Import the module
from importfrom import twitter

# Parse and exec functions
functions = twitter('')

# Assign functions to variables
hello = functions['hello']
bye = functions['bye']

# Call and use functions as normal
print('%s\n%s' % (hello('world'), bye('world')))

The DNS function has to be handled slightly differently. Create a TXT record for a distinct subdomain on your domain, and place your code in that. If there are multiple TXT records then there's no guarantee as to which one will be chosen.

Here's an example:

hello = dns('')['hello']
bye = dns('')['bye']

If the service you want isn't already implemented, you can add it yourself!

from importfrom import magic

# Code to grab a string containing the functio(n|ns).
string = """
def hello(name):
    return 'Hello, %s!' % name

def bye(name):
    return 'Bye, %s!' % name

functions = magic(string)

hello = functions['hello']
bye = functions['bye']

print('%s\n%s' % (hello('world'), bye('world')))

If you do add another service, consider contributing by opening a pull request.