I started poking around and noticed that in
django.core.management.commands.shell, there's line 50 or so:
if not use_plain:
# here's where it uses PYTHONSTARTUP and stuff
Why the heck is that "if not use_plain" there? If I take it out,
Collin's lovely history script works, even in the Django shell. And I
can't figure out what it's there for. Should I submit a patch, or is
there a reason it exists?
Todd
It's the variable that says whether or not the option --plain was
used. It determines whether the normal Python shell is used or
iPython. iPython is used if available unless --plain is set.
Cheers,
deryck
Hmm, that sounds like a bug then, as this happens even when ipython
isn't present, so it should be parsing the normal stuff in that case, right?
--
Collin Grady
A robin redbreast in a cage
Puts all Heaven in a rage.
-- Blake
Hi, Todd.
Were you using --plain and still wanting the history and tab
completion, or was use_plain being incorrectly set? If use_plain was
causing PYTHONSTARTUP to not be recognized, but you didn't use
--plain, then we need to figure out why that is, rather than just
removing the use_plain check.
If you were using --plain, and just want to have PYTHONSTARTUP
recognized with the plain shell, then the patch makes sense to me.
Cheers,
deryck
At any rate, I don't think it matters whether you use --plain or not.
If you use --plain, you'd expect to get normal behavior for typing
python at a terminal prompt, which does use PYTHONSTARTUP. If you
don't use --plain and don't have IPython installed, why should you not
just get the normal behavior you'd expect from using plain Python,
i.e., respecting the PYTHONSTARTUP environment variable?
Todd
On Nov 14, 2007 9:04 AM, Todd O'Bryan <toddo...@gmail.com> wrote:
>
> Good point. In fact, I wasn't using --plain, but PYTHONSTARTUP wasn't
> being respected anyway. Any ideas why the heck that should happen?
No idea, sorry. :-) I'd attach with pdb and walk through how the
options are being set and try to deduce why you're getting this
behavior. That's how I would handle it, but others will certainly
have there own ideas.
This is the real bug here, so it would be nice to see why it happens for you.
>
> At any rate, I don't think it matters whether you use --plain or not.
> If you use --plain, you'd expect to get normal behavior for typing
> python at a terminal prompt, which does use PYTHONSTARTUP. If you
> don't use --plain and don't have IPython installed, why should you not
> just get the normal behavior you'd expect from using plain Python,
> i.e., respecting the PYTHONSTARTUP environment variable?
>
I would agree with this, too. I think the initial thought when this
was added during the last sprint was that plain implies nothing extra,
but really I think it should be the plain shell as you have it setup
by honoring PYTHONSTARTUP or pythonrc.
It might be nice to update the ticket to point to this discussion with
a note summarizing, since it's not really the real bug.
Cheers,
deryck
So the issue now is that shell --plain doesn't use PYTHONSTARTUP,
which both Deryck and I think it should. :-) I've modified the ticket
to reflect the real state of affairs.