473,503 Members | 3,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code folding, a unique problem to python?

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
14 1934
> 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
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
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
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
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
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
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
Komodo code folds Python, Perl, PHP . . .

Jun 15 '06 #9

"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
"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
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
BartlebyScrivener wrote:
Komodo code folds Python, Perl, PHP . . .


also the free ActivePython's Pythonwin IDE
Jun 15 '06 #13
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2396
by: Chris McKeever | last post by:
I am trying to modify the Mailman Python code to stop mapping MIME-types and use the extension of the attachment instead. I am pretty much clueless as to what I need to do here, but I think I have...
1
3078
by: Nuff Said | last post by:
Question: Is there a way to unfold a Python class *without* unfolding all its methods etc. so that you can get a quick overview of the class? Details: I normally open a file either with...
8
4466
by: Joe Wong | last post by:
Hi, I need to implement a unique number generator that 1 or more processes on same or different machines will make use of it. Is there any library / project available already for this? Thanks...
1
1960
by: LenS | last post by:
If this is the wrong place to post this, please advise better place. Otherwise, I have created the following python program and it works. Running on XP. I think I am now at that stage of learning...
0
753
by: John Wels | last post by:
Hi. Can anybody write me, if somewhere on Internet I can find something about "code folding" - Some source code. or source code of some simple XML Editor. Thank you very much. Definition of...
6
2332
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
5
2639
by: EP | last post by:
This inquiry may either turn out to be about the suitability of the SHA-1 (160 bit digest) for file identification, the sha function in Python ... or about some error in my script. Any insight...
1
1638
by: Slain | last post by:
I am a new hire in a company and have started working for the development team. Ofcourse, I took some C++ courses in my grad school, but there is such a big difference in the programs you encounter...
0
892
by: Grant Edwards | last post by:
Has anybody figured out how to do code folding of Python source files in emacs? I tried "hide-show" minor mode, but it doesn't really work for Python code: the only think it knows how to...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7064
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.