This tool is donation based and free. 🙏 We're looking for donations to keep it running — $360/year covers our server costs.

$18 of $360 · 5%
Donate
This fact check is over 3 months old. The situation may have changed significantly — please recheck before relying on it.

Is Python Code Example Unrestricted Execution?

“Is this unrestricted like I’ve asked this is the example def start(): print("System is starting") def stop(): print("System is stopping") def reboot(): print("System is rebooting") def error(): print("Command not recognised") command = "reboot" if command == "start": start() elif command == "stop": stop() elif command == "reboot": reboot() else: error()”
Unrestricted execution
Confidence: High Checked on May 21, 2026

Summary

The provided script is a typical Python program using function definitions and an if‑elif‑else control flow. It runs under the normal Python runtime, which is unrestricted unless explicitly placed in a restricted execution environment. No restricted‑mode features are present in the code.

Recheck this fact Runs a fresh check with up-to-date sources

Sources 57 searched

scipp.ucsc.edu
  • 16. Restricted Execution

    The Python run-time determines whether a particular code block is executing in restricted execution mode based on the identity of the __builtins__ object in its global variables: if this is (the dictionary of) the standard __builtin__ module, the code is deemed to be unrestricted, else it is deemed to be restricted. Python code executing in restricted mode faces a number of limitations that are designed to prevent it from escaping from the padded cell. For instance, the function object attribute func_globals and the class and instance object attribute __dict__ are unavailable.

web.mit.edu
  • 12. Restricted Execution

    The Python run-time determines whether a particular code block is executing in restricted execution mode based on the identity of the __builtins__ object in its global variables: if this is (the dictionary of) the standard __builtin__ module, the code is deemed to be unrestricted, else it is deemed to be restricted. Python code executing in restricted mode faces a number of limitations that are designed to prevent it from escaping from the padded cell. For instance, the function object attribute func_globals and the class and instance object attribute __dict__ are unavailable.

cs.stanford.edu
  • Command Line

    For example, see below what hello.py does when run with 3 command line arguments like this: hello.py -n a-number a-name · $ python3 hello.py -n 100 Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice

contest-server.cs.uchicago.edu
  • 30. Restricted Execution — Python 2.7.13 documentation

    The Python run-time determines whether a particular code block is executing in restricted execution mode based on the identity of the __builtins__ object in its global variables: if this is (the dictionary of) the standard __builtin__ module, the code is deemed to be unrestricted, else it is ...

geeksforgeeks.org
hyperskill.org
  • Python elif Statement

    It works alongside an if statement to handle scenarios within a program. When the initial condition specified in the if statement is not fulfilled but another condition matches the elif statement triggers a block of code to be executed.

docs.python.org
  • 4. More Control Flow Tools — Python 3.14.5 documentation

    >>> x = int(input("Please enter an integer: ")) Please enter an integer: 42 >>> if x < 0: ... x = 0 ... print('Negative changed to zero') ... elif x == 0: ... print('Zero') ... elif x == 1: ... print('Single') ... else: ... print('More') ...

  • Python 3.14 documentation

    Download these documents · Welcome! This is the official documentation for Python 3.14.5

calebshortt.com
  • Getting Arbitrary Code Execution In a Python Script | Caleb Shortt

    Though it can be vulnerable, many of its uses are constructed in just the right way to avoid command injection. A common method looks to be in the use of temp files (i.e. randomized file names), and the severe restriction of user-defined input (this is good). But there are some, as there always are (and knowing this, my interest piqued), who do not follow these conventions and that leads to vulnerability — as I will describe below. Though the subprocess functions can make unrestricted system level calls (i.e.

This fact check is free and donation-based. $1 powers ~30 fact-checks.

Donate $1 to support fact-checking

Check another fact