Opened 9 years ago

Closed 9 years ago

#25536 closed New feature (wontfix)

Add support for ptpython shell

Reported by: Matheus Rosa Owned by: Matheus Rosa
Component: Core (Management commands) Version: 1.8
Severity: Normal Keywords: python shell
Cc: matheusdsrosa@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I would like to add support for the ptpython shell. ptpython is very powerful, lightweight shell for Python. https://github.com/jonathanslenders/ptpython.

The implementation is very simple. I've already done this in my local clone of django in a local branch based from master. Here is the diff:

diff --git i/django/core/management/commands/shell.py w/django/core/management/commands/shell.py
index d8bded0..e52af95 100644
--- i/django/core/management/commands/shell.py
+++ w/django/core/management/commands/shell.py
@@ -4,13 +4,13 @@ from django.core.management.base import BaseCommand


 class Command(BaseCommand):
-    help = "Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available."
+    help = "Runs a Python interactive interpreter. Tries to use IPython, bpython or ptpython, if one of them is available."
     requires_system_checks = False
-    shells = ['ipython', 'bpython']
+    shells = ['ipython', 'bpython', 'ptpython']

     def add_arguments(self, parser):
         parser.add_argument('--plain', action='store_true', dest='plain',
-            help='Tells Django to use plain Python, not IPython or bpython.')
+            help='Tells Django to use plain Python, not IPython, bpython or ptpython.')
         parser.add_argument('--no-startup', action='store_true', dest='no_startup',
             help='When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.')
         parser.add_argument('-i', '--interface', choices=self.shells, dest='interface',
@@ -50,6 +50,10 @@ class Command(BaseCommand):
         import bpython
         bpython.embed()

+    def ptpython(self):
+        from ptpython.repl import embed
+        embed(globals(), locals())
+
     def run_shell(self, shell=None):
         available_shells = [shell] if shell else self.shells

I don't think tests are needed since I didn't find tests for the ipython and bpython shells.

Attachments (1)

100644.diff (1.5 KB ) - added by Matheus Rosa 9 years ago.
Diff file

Download all attachments as: .zip

Change History (3)

by Matheus Rosa, 9 years ago

Attachment: 100644.diff added

Diff file

comment:1 by Matheus Rosa, 9 years ago

Cc: matheusdsrosa@… added
Owner: changed from nobody to Matheus Rosa
Status: newassigned

comment:2 by Tim Graham, 9 years ago

Resolution: wontfix
Status: assignedclosed

Closing as "wontfix" based on discussion in #19737. Feel free to write to the DevelopersMailingList if you disagree with the conclusions of that ticket. Thanks!

Note: See TracTickets for help on using tickets.
Back to Top