Skip to content

Add !exec alias to clarify command behavior #3390

@jb3

Description

@jb3

Opened on behalf of @python-discord/devops

Problem

Earlier today I received notice from my Vice-Best Man @ChrisLovering that we were misinforming users who were using the !eval command functionality of this project.

Chris rightly pointed out that the !eval command behavior is actually really !exec - we spawn a new Python process to execute the user's code, going far beyond the capabilities of the plain old eval() built-in.

Current Behavior

The !eval command currently:

  • Sends user input to snekbox
  • Spawns a new Python subprocess
  • Executes arbitrary Python code (statements, not just expressions)
  • Supports multi-line code blocks
  • Allows imports, variable assignments, control flow, etc.
  • Captures and returns stdout/stderr

This is fundamentally different from Python's eval() function, which:

  • Only evaluates single expressions
  • Cannot execute statements like assignments or imports
  • Runs in the current process context
  • Is limited to expression evaluation

Proposed Solution

Add an !exec alias that provides the same functionality as !eval.

Benefits

  • Accuracy: The command name reflects what it actually does
  • User Education: Helps users understand the difference between eval() and exec()
  • Clarity: New users won't be confused about the scope of execution
  • Best Practices: Aligns with Python terminology and conventions

Implementation Notes

  • The alias should be a simple addition that maps !exec to the existing !eval functionality
  • No breaking changes to existing !eval usage
  • Both commands should have identical behavior.
  • Help text should be updated to mention both aliases

Acceptance Criteria

  • !exec command works identically to !eval
  • No regression in existing !eval functionality
  • Consider adding a gentle notice about exec behaviour.

Additional Context

This change would help align our tool's terminology with standard Python concepts and reduce confusion for users learning about the differences between eval() and exec() in Python.

Metadata

Metadata

Labels

a: frontendRelated to output and formattinga: utilityRelated to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils)good first issueGood for newcomersl: 0 - beginnerp: -1 - super criticalSubstance at a temperature and pressure above its critical pointstatus: approvedThe issue has received a core developer's approvalt: enhancementChanges or improvements to existing features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions