Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8602721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:09:12+00:00 2026-06-12T02:09:12+00:00

I am using google app engine and I am trying to basically allow users

  • 0

I am using google app engine and I am trying to basically allow users to upload code, where it will later be executed by the server. I also have to be able to send variables to the scripts, which is why initially when I was running everything on my desktop, I Imported everything dynamically (as in- the name of the script is stored in a variable). But now I can not do this because of the filesystem in the google app engine environment.

I already have a database setup so that I can get the code in plain-text. But now I would like to know if there was any way that I could import a python script, not from a file but from a variable containing python code.

For example, If this was the plain-text code, how could I get this to execute properly:

code = """
def Main(var):
    print "you entered: " + var
"""
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:09:13+00:00Added an answer on June 12, 2026 at 2:09 am

    First, create a module for the code to live in:

    # define module_name somewhere
    import types
    module = types.ModuleType(module_name)
    

    You’ll probably want to register that module, too:

    import sys
    sys.modules[module_name] = module
    

    Then compile the code:

    # source should the code to execute
    # filename should be a pseudo-filename that the code's from
    # (it doesn't actually have to exist; it's used for error messages)
    code_object = compile(source, filename, 'exec')
    

    Then execute the code object in the context of the module:

    exec code_object in module.__dict__
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a Google App Engine Go application that will be using
The goal: Using Google App Engine server and Android client, I'm trying to put
Using Google App Engine, I am trying to urlfetch a gzip file from a
I am trying to fetch URLs using Google App Engine's urlFetch service and implement
I'm using Django templating with Google App Engine. I'm trying unsuccessfully to print out
I am using Google App Engine (python), I want my users to be able
I am using Google App Engine with the Datastore interface. Whenever I'm trying to
Im trying to use http://www.javarants.com/2008/04/13/using-google-app-engine-to-extend-yahoo-pipes/ as inspiration, but I'm having some troubles with the
I am trying to make a simple application using Google App Engine. Below is
i'm trying to make out with web-apps on java using google app engine. i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.