I may be missing something here. Why doesn't PyCrust indent the code
more than one time?
For example, if I write `while True:` and then press Enter, it will
start the next line with one indentation. If I write `while True:` and
press Enter again, it would remain at the same level of one
indentation. Why is this?
cool-RR wrote:
I may be missing something here. Why doesn't PyCrust indent the code
more than one time?
For example, if I write `while True:` and then press Enter, it will
start the next line with one indentation. If I write `while True:` and
press Enter again, it would remain at the same level of one
indentation. Why is this?
I remember wondering the same thing when PyCrust was new and I asked Patrick about it. Unfortunately I don't remember what he said, but it seems there was a reason that made sense.
···
--
Robin Dunn
Software Craftsman
Patrick says:
···
###################################
Hi Ram,
The answer is that I simply never got around to implementing that
feature. I'm no longer actively working on PyCrust so someone else
will have to take on that challenge. Feel free to forward this reply
to the list.
Pat
--
Patrick K. O'Brien
Orbtech
###################################
I guess that might qualify as "a reason that makes sense"
I wonder how so much effort as gone into PyCrust, as can be seen on
its history page, and still the indentation thing got put on the
backburner.
Anyway, does anyone know of any other attempt to make a good Python
shell?
Ram.
I remember wondering the same thing when PyCrust was new and I asked
Patrick about it. Unfortunately I don't remember what he said, but it
seems there was a reason that made sense.--
Robin Dunn
Software Craftsmanhttp://wxPython.org
Ram,
···
On Jun 4, 3:17 pm, cool-RR <ram.rac...@gmail.com> wrote:
Patrick says:
###################################
Hi Ram,The answer is that I simply never got around to implementing that
feature. I'm no longer actively working on PyCrust so someone else
will have to take on that challenge. Feel free to forward this reply
to the list.Pat
--
Patrick K. O'Brien
Orbtech
###################################I guess that might qualify as "a reason that makes sense"
I wonder how so much effort as gone into PyCrust, as can be seen on
its history page, and still the indentation thing got put on the
backburner.Anyway, does anyone know of any other attempt to make a good Python
shell?Ram.
> I remember wondering the same thing when PyCrust was new and I asked
> Patrick about it. Unfortunately I don't remember what he said, but it
> seems there was a reason that made sense.> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.org
Looks like Editra sort of works in that while the indents work on
nested conditionals, IMO the indents are too much. My preferences say
that it should indent 4 characters, but it indents to right beneath
the colon. Weird.
- Mike
Hello,
Ram,
Patrick says:
I guess that might qualify as "a reason that makes sense"
I wonder how so much effort as gone into PyCrust, as can be seen on
its history page, and still the indentation thing got put on the
backburner.
It would probably be easy to patch it to do so, for simple indentation
based on the previous line, as it already does so for the first line.
If your interested in adding this ability why not take 15 min to look
into adding it, the source is open and available
Anyway, does anyone know of any other attempt to make a good Python
shell?
IPython has a wx based front end for it shell as well. If your run a
source version of Editra and have a recent ipython installed there is
a plugin 'IPyShell' that you can install to try it out.
Looks like Editra sort of works in that while the indents work on
nested conditionals, IMO the indents are too much. My preferences say
that it should indent 4 characters, but it indents to right beneath
the colon. Weird.
Are you talking about the text editing area or the or the PyShell
plugin? The pyshell plugin is simply using the pycrust shell so it
will act the same. The buffer area is using its own autoindent code.
If its in the buffer area, you should look at if there are tabs in
your file and what the tab vs indent settings are as well as the width
tabs are interpreted as.
Cody
···
On Thu, Jun 4, 2009 at 3:25 PM, Mike Driscoll <kyosohma@gmail.com> wrote:
On Jun 4, 3:17 pm, cool-RR <ram.rac...@gmail.com> wrote:
It would probably be easy to patch it to do so, for simple indentation
based on the previous line, as it already does so for the first line.
If your interested in adding this ability why not take 15 min to look
into adding it, the source is open and available
You're too optimistic about me. I doubt it would take me anything as
short as 15 minutes. Not even to make it remotely work. Sorry.
>> Anyway, does anyone know of any other attempt to make a good Python
>> shell?IPython has a wx based front end for it shell as well. If your run a
source version of Editra and have a recent ipython installed there is
a plugin 'IPyShell' that you can install to try it out.
I found its site, it seems not to support anything beyond Python 2.5.
···
--
I am generally dissatisfied with Python shells, wxPython-based or
otherwise. I've tried IDLE, PyCrust, PythonWin, IPython, and the
default Python shell. They all have one or more deficiencies that I
find annoying. The "best" is IDLE: Its biggest weakness is the weird
caret behavior. (Basically, that you have to manually place the caret
after the `>>>` prompt in order to be able to write.) And then there
is that weird network-loopback thing.
The reason that I'm so obsessed about a shell, is that I'm working on
a Python learning environment for beginners, Python Turtle, which will
be very much like that old LOGO thing. (You can Google it if you don't
know what that is.)
That is why I'm obsessed with having an easy-to-use shell... Does
someone have any other suggestion?
Ram.
Hello,
···
On Jun 4, 2009, at 4:03 PM, cool-RR wrote:
It would probably be easy to patch it to do so, for simple indentation
based on the previous line, as it already does so for the first line.
If your interested in adding this ability why not take 15 min to look
into adding it, the source is open and availableYou're too optimistic about me. I doubt it would take me anything as
short as 15 minutes. Not even to make it remotely work. Sorry.
Oh my, you never know till you try, shouldn't give up on something so easily.
It ended up only being about 5 lines of actual code, merry early xmas.
see: wxTrac has been migrated to GitHub Issues - wxWidgets
Cody
Nice!
Although there is one bug there. When you type something like:
def f(x): return 4
It still indents, even though it shouldn't. I guess the regular
expression should be modified, and I don't know regular expressions...
Can you do it?
I have changed it to use tabs though, I think it's better since you
can hit backspace just one time instead of 4 in order to de-indent.
And I'm looking into making the caret automatically move to the input
zone when you type... Working at that.
···
On Jun 5, 6:33 am, Cody Precord <codyprec...@gmail.com> wrote:
Hello,
On Jun 4, 2009, at 4:03 PM, cool-RR wrote:
>> It would probably be easy to patch it to do so, for simple
>> indentation
>> based on the previous line, as it already does so for the first line.
>> If your interested in adding this ability why not take 15 min to look
>> into adding it, the source is open and available> You're too optimistic about me. I doubt it would take me anything as
> short as 15 minutes. Not even to make it remotely work. Sorry.Oh my, you never know till you try, shouldn't give up on something so
easily.It ended up only being about 5 lines of actual code, merry early xmas.
see:wxTrac has been migrated to GitHub Issues - wxWidgets
Cody
Hello,
Nice!
Although there is one bug there. When you type something like:def f(x): return 4
It still indents, even though it shouldn't. I guess the regular
expression should be modified, and I don't know regular expressions...
Can you do it?
Missed that, patch updated, just add a $ to the end of the regex string.
I have changed it to use tabs though, I think it's better since you
can hit backspace just one time instead of 4 in order to de-indent.
I would stick with spaces, you can set SetBackSpaceUnIndents(True) to get the same behavior using spaces, or by hitting Shift+Tab to unindent one level.
And I'm looking into making the caret automatically move to the input
zone when you type... Working at that.
Just look for the key handler where it checks if it should allow input or not, and instead of just swallowing the key event move the carat and except the input. (think you just need to add a self.GotoPos(self.GetLength())).
Cody
···
On Jun 5, 2009, at 6:12 AM, cool-RR wrote:
No good: Now it just doesn't indent, even when it should.
···
On Jun 5, 2:38 pm, Cody Precord <codyprec...@gmail.com> wrote:
Hello,
On Jun 5, 2009, at 6:12 AM, cool-RR wrote:
> Nice!
> Although there is one bug there. When you type something like:> def f(x): return 4
> It still indents, even though it shouldn't. I guess the regular
> expression should be modified, and I don't know regular expressions...
> Can you do it?Missed that, patch updated, just add a $ to the end of the regex string.
Also, regarding SetBackSpaceUnIndents(True), whose method is it and
when do I call it?
Hello,
···
On Jun 5, 2009, at 6:42 AM, cool-RR wrote:
Nice!
Although there is one bug there. When you type something like:def f(x): return 4
It still indents, even though it shouldn't. I guess the regular
expression should be modified, and I don't know regular expressions...
Can you do it?Missed that, patch updated, just add a $ to the end of the regex string.
No good: Now it just doesn't indent, even when it should.
Are you sure you haven't changed something else that affects this, as this works fine for me.
cody
Just look for the key handler where it checks if it should allow input
or not, and instead of just swallowing the key event move the carat
and except the input. (think you just need to add a
self.GotoPos(self.GetLength())).
This gets more complicated. I tried it, but then when I type a
character it would move me to the right place but not type it, even
though I did event.Skip. Also, when just using shift and/or control to
select text in the readonly section, it still transfers you to the
input zone. Also, typing Enter does not transfer you to the input
zone, and I think it should.
Hello,
···
On Jun 5, 2009, at 6:44 AM, cool-RR wrote:
Also, regarding SetBackSpaceUnIndents(True), whose method is it and
when do I call it?
Its a method of the StyledTextCtrl. shell.Shell derives from it so you would use it there.
cody
I reinstalled wxPython now and applied your patch again, still not
working. Maybe it's because I'm on Windows or something?
···
On Jun 5, 3:06 pm, Cody Precord <codyprec...@gmail.com> wrote:
Hello,
On Jun 5, 2009, at 6:42 AM, cool-RR wrote:
>>> Nice!
>>> Although there is one bug there. When you type something like:>>> def f(x): return 4
>>> It still indents, even though it shouldn't. I guess the regular
>>> expression should be modified, and I don't know regular
>>> expressions...
>>> Can you do it?>> Missed that, patch updated, just add a $ to the end of the regex
>> string.> No good: Now it just doesn't indent, even when it should.
Are you sure you haven't changed something else that affects this, as
this works fine for me.cody
Hello,
···
On Fri, Jun 5, 2009 at 7:27 AM, cool-RR<ram.rachum@gmail.com> wrote:
I reinstalled wxPython now and applied your patch again, still not
working. Maybe it's because I'm on Windows or something?
The only difference that I could think of would perhaps be the end of
line characters. Try stripping the trailing whitespace to see if it
behaves any differently.
i.e) RE_INDENT_LINE.match(text.rstrip())
Cody
Hi Cody,
<snip>
> Looks like Editra sort of works in that while the indents work on
> nested conditionals, IMO the indents are too much. My preferences say
> that it should indent 4 characters, but it indents to right beneath
> the colon. Weird.Are you talking about the text editing area or the or the PyShell
plugin? The pyshell plugin is simply using the pycrust shell so it
will act the same. The buffer area is using its own autoindent code.If its in the buffer area, you should look at if there are tabs in
your file and what the tab vs indent settings are as well as the width
tabs are interpreted as.Cody
I don't know. I'm using the Editra that comes with wxPython, version
0.4.42. I haven't installed any plugins that I can recall.
Anyway, I just open an instance of Editra, then save the blank
document as a Python file. Then I type something silly in like this:
<snippet>
if x > 10:
if y < 12:
print "borked!'
</snippet>
My Preferences say that my Tab Width is 8, Indent Width is 4. I'm not
pressing tab or even the space bar after the colons above. I just hit
<enter> when I reach the end of the statement and it auto-indents like
that.
- Mike
Hello,
Hi Cody,
<snip>
> Looks like Editra sort of works in that while the indents work on
> nested conditionals, IMO the indents are too much. My preferences say
> that it should indent 4 characters, but it indents to right beneath
> the colon. Weird.Are you talking about the text editing area or the or the PyShell
plugin? The pyshell plugin is simply using the pycrust shell so it
will act the same. The buffer area is using its own autoindent code.If its in the buffer area, you should look at if there are tabs in
your file and what the tab vs indent settings are as well as the width
tabs are interpreted as.Cody
I don't know. I'm using the Editra that comes with wxPython, version
0.4.42. I haven't installed any plugins that I can recall.
It comes with the PyShell plugin, but I can tell from below that you
are referring to the text editing area.
Anyway, I just open an instance of Editra, then save the blank
document as a Python file. Then I type something silly in like this:<snippet>
if x > 10:
if y < 12:
print "borked!'</snippet>
My Preferences say that my Tab Width is 8, Indent Width is 4. I'm not
pressing tab or even the space bar after the colons above. I just hit
<enter> when I reach the end of the statement and it auto-indents like
that.
Sorry, I don't see whats wrong in that snippet. Each level of
indentation appears to be increased correctly (though email may have
distorted it).
If you have "Use Tabs Instead of Spaces" enabled it would be inserting
tab characters for indentation that are displayed as 8 columns wide
(as per your settings) for each level of indentation.
Cody
···
On Fri, Jun 5, 2009 at 8:22 AM, Mike Driscoll<kyosohma@gmail.com> wrote:
It would probably be easy to patch it to do so, for simple indentation
based on the previous line, as it already does so for the first line.
If your interested in adding this ability why not take 15 min to look
into adding it, the source is open and availableYou're too optimistic about me. I doubt it would take me anything as
short as 15 minutes. Not even to make it remotely work. Sorry.>> Anyway, does anyone know of any other attempt to make a good Python
>> shell?IPython has a wx based front end for it shell as well. If your run a
source version of Editra and have a recent ipython installed there is
a plugin 'IPyShell' that you can install to try it out.I found its site, it seems not to support anything beyond Python 2.5.
--
I am generally dissatisfied with Python shells, wxPython-based or
otherwise. I've tried IDLE, PyCrust, PythonWin, IPython, and the
default Python shell. They all have one or more deficiencies that I
find annoying. The "best" is IDLE: Its biggest weakness is the weird
caret behavior. (Basically, that you have to manually place the caret
after the `>>>` prompt in order to be able to write.) And then there
is that weird network-loopback thing.
There are actually some really good reasons for the loopback socket.
And fixing the caret behavior shouldn't be too horrible, you may want
to look into it (if you would prefer to use idle).
The reason that I'm so obsessed about a shell, is that I'm working on
a Python learning environment for beginners, Python Turtle, which will
be very much like that old LOGO thing. (You can Google it if you don't
know what that is.)
That is why I'm obsessed with having an easy-to-use shell... Does
someone have any other suggestion?
Aside from the indentation stuff, is there anything else that is a
problem in PyCrust?
- Josiah
···
On Thu, Jun 4, 2009 at 2:03 PM, cool-RR<ram.rachum@gmail.com> wrote:
Aside from the indentation stuff, is there anything else that is a
problem in PyCrust?- Josiah
I'm glad you asked, Josiah.
Problems I can currently think of, by order of severity:
Problem 1: This indentation stuff.
Problem 2: The traceback gets color-coded. (Can get ugly sometimes.)
Problem 3: It would be nice to unindent automatically after a "return"
statement. Not critical.
And another thing, which I would place above "Problem 2" in priority
but which isn't strictly a problem but something I'd like to do, and a
guy called Basegmez tried to help me, but I didn't succeed in doing
it: Making PyShell control a separate process, created by the
multiprocessing package.