By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,220 Members | 1,798 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,220 IT Pros & Developers. It's quick & easy.

code folding, a unique problem to python?

P: n/a
Specifically, I'm using UltraEdit and perhaps there's no way perfect way
to implement code folding with it, given how it uses its syntax
highlighting file to do so (i.e., you have to specify an "Opening" and
"Closing" character in which to enfold code, such as braces).

But my question is more general: is it possible to implement code
folding with Python given that it has no real block delimiters? Or is
this still a matter of which particular editor/IDE you use? For my part
I've tried (as was suggested elsewhere) to use 'def' as an opening and
closing keyword, but this of course will enfold everything between two
defs, even if you have more code between your function definitons (such
as a new class definition).

So maybe I'm stuck in UE, but I'm curious if there is some general way
to do this, or is Python just too simple and concise for its own good? :)
Jun 15 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a
> But my question is more general: is it possible to implement
code folding with Python given that it has no real block
delimiters? Or is this still a matter of which particular
editor/IDE you use?
Yes, it is an editor thing. In Vim, it's as simple as

:set foldmethod=indent

and presto! I'm sure other quality editors provide similar
options. ;)
So maybe I'm stuck in UE, but I'm curious if there is some
general way to do this, or is Python just too simple and
concise for its own good? :)


Most editors are "just too simple and concise for [their] own
good". :)

-tkc


Jun 15 '06 #2

P: n/a
John Salerno írta:
Specifically, I'm using UltraEdit and perhaps there's no way perfect way
to implement code folding with it, given how it uses its syntax
highlighting file to do so (i.e., you have to specify an "Opening" and
"Closing" character in which to enfold code, such as braces).

But my question is more general: is it possible to implement code
folding with Python given that it has no real block delimiters? Or is
this still a matter of which particular editor/IDE you use? For my part
I've tried (as was suggested elsewhere) to use 'def' as an opening and
closing keyword, but this of course will enfold everything between two
defs, even if you have more code between your function definitons (such
as a new class definition).

So maybe I'm stuck in UE, but I'm curious if there is some general way
to do this, or is Python just too simple and concise for its own good? :)


There are many editors that do this. For Python, folding is based on
IDENT and DEDENT tokens. You can look for their definition in the Python
Language Reference.

For example, SPE can do this. See this screenshot:

http://stani.be/python/spe/screensho...ux-blender.png
Best,

Laszlo

Jun 15 '06 #3

P: n/a
John Salerno wrote:
But my question is more general: is it possible to implement code
folding with Python given that it has no real block delimiters? Or is
this still a matter of which particular editor/IDE you use?


since the Python syntax *has* real block delimiters (look up INDENT and
DEDENT in the language reference), it's an editor issue.

</F>

Jun 15 '06 #4

P: n/a
John Salerno schrieb:
Specifically, I'm using UltraEdit and perhaps there's no way perfect way
to implement code folding with it, given how it uses its syntax
highlighting file to do so (i.e., you have to specify an "Opening" and
"Closing" character in which to enfold code, such as braces).

But my question is more general: is it possible to implement code
folding with Python given that it has no real block delimiters? Or is
this still a matter of which particular editor/IDE you use? For my part
I've tried (as was suggested elsewhere) to use 'def' as an opening and
closing keyword, but this of course will enfold everything between two
defs, even if you have more code between your function definitons (such
as a new class definition).

So maybe I'm stuck in UE, but I'm curious if there is some general way
to do this, or is Python just too simple and concise for its own good? :)


Eric3, the Qt-based and in python written IDE can do that. So I'd say
it's an UE-problem - nad it has to be: to perform folding, one has to
find out what constitutes a block. Obviously this CAN be done with
python-code - do it CAN be done in editor code.

Diez
Jun 15 '06 #5

P: n/a
Fredrik Lundh wrote:
John Salerno wrote:
But my question is more general: is it possible to implement code
folding with Python given that it has no real block delimiters? Or is
this still a matter of which particular editor/IDE you use?


since the Python syntax *has* real block delimiters (look up INDENT and
DEDENT in the language reference), it's an editor issue.

</F>


Interesting. This might help me then, assuming UE can use characters
other than strings to delimit blocks.

Thanks!
Jun 15 '06 #6

P: n/a
Diez B. Roggisch wrote:
Eric3, the Qt-based and in python written IDE can do that. So I'd say
it's an UE-problem - nad it has to be: to perform folding, one has to
find out what constitutes a block. Obviously this CAN be done with
python-code - do it CAN be done in editor code.


::lowers head in embarassment:: I wanted to try out Eric3, but I
couldn't figure out how to install it! Is there a binary file? All I
found was a zipped file with a bunch of stuff I didn't recognize in it.
There was even a file called eric3.py which I thought might be it, but
running it did nothing.
Jun 15 '06 #7

P: n/a
John Salerno napisa³(a):
::lowers head in embarassment:: I wanted to try out Eric3, but I
couldn't figure out how to install it! Is there a binary file? All I
found was a zipped file with a bunch of stuff I didn't recognize in it.
There was even a file called eric3.py which I thought might be it, but
running it did nothing.


You'll need PyQt to run that one. And QScintilla too.

--
Jarek Zgoda
http://jpa.berlios.de/
Jun 15 '06 #8

P: n/a
Komodo code folds Python, Perl, PHP . . .

Jun 15 '06 #9

P: n/a

"John Salerno" <jo******@NOSPAMgmail.com> wrote in message
news:jx******************@news.tufts.edu...
Specifically, I'm using UltraEdit and perhaps there's no way perfect way
to implement code folding with it, given how it uses its syntax
highlighting file to do so (i.e., you have to specify an "Opening" and
"Closing" character in which to enfold code, such as braces).

But my question is more general: is it possible to implement code
folding with Python given that it has no real block delimiters? Or is
this still a matter of which particular editor/IDE you use? For my part
I've tried (as was suggested elsewhere) to use 'def' as an opening and
closing keyword, but this of course will enfold everything between two
defs, even if you have more code between your function definitons (such
as a new class definition).

So maybe I'm stuck in UE, but I'm curious if there is some general way
to do this, or is Python just too simple and concise for its own good? :)

Jun 15 '06 #10

P: n/a
"John Salerno" <jo******@NOSPAMgmail.com> wrote in message
news:jx******************@news.tufts.edu...

But my question is more general: is it possible to implement code
folding with Python given that it has no real block delimiters?


SciTE can fold Python.
Jun 15 '06 #11

P: n/a
On 2006-06-15, Paul McGuire <pt***@austin.rr._bogus_.com> wrote:
"John Salerno" <jo******@NOSPAMgmail.com> wrote in message
news:jx******************@news.tufts.edu...

But my question is more general: is it possible to implement code
folding with Python given that it has no real block delimiters?


SciTE can fold Python.


If only there were a way for users to bind key-sequences...

--
Grant Edwards grante Yow! I was making donuts
at and now I'm on a bus!
visi.com
Jun 15 '06 #12

P: n/a
BartlebyScrivener wrote:
Komodo code folds Python, Perl, PHP . . .


also the free ActivePython's Pythonwin IDE
Jun 15 '06 #13

P: n/a
Paul McGuire napisa³(a):
But my question is more general: is it possible to implement code
folding with Python given that it has no real block delimiters?


SciTE can fold Python.


All other good editors can too. So general answer to this question is
"yes". Because Python *has* real block delimiters...

--
Jarek Zgoda
http://jpa.berlios.de/
Jun 15 '06 #14

P: n/a
John Salerno wrote:
But my question is more general: is it possible to
implement code folding with Python given that it has
no real block delimiters?


I can't speak for UltraEdit, but the Zeus will quite
happily fold Python code:

http://www.zeusedit.com/features.html

Jussi Jumppanen
Author: Zeus For Windows IDE

Jun 16 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.