473,769 Members | 5,131 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 1957
> 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=inde nt

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******@NOSPA Mgmail.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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2416
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 narrowed it down to the Scrubber.py file.. If this seems like a quick step me through, I would be very appreciative, could get you something on your Amazon wish-list (that is me on my knees begging).. From just my basic understanding, it...
1
3099
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 'fold.on.open=1' set in the user's options file resp. I use 'toggle all folds' from
8
4484
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 in advance, -- Wong
1
1977
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 python where I'm not quit a newbie and I am not really knowlegable. I know just enough to be dangerous and can really screw things up. Any suggestion on improving would be greatly appreciated. However my real question is I would like to run...
0
758
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 Code folding. Code folding is a feature of some IDEs allowing the user to collapse sections of a source code file while working in other parts of it. This
6
2347
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 solution. My code can be downloaded from here: http://www.tprimke.net/konto/PyObject-problem.tar.bz2. There are some scripts for GNU/Linux system (bash to be precise). All you need to know is that there are four classes. (Of course, you may...
5
2657
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 appreciated in advance. I am trying to reduce duplicate files in storage at home - I have a large number files (e.g. MP3s) which have been stored on disk multiple times under different names or on different paths. The using applications will...
1
1651
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 at school versus here, where it sems there is a completely different style of writing. Is there some tool etc to help understand some one else's code. I have been given some responsibilities to fix some minor defects, which involves...
0
906
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 hide/show are function bodies. It can't do normal things like hide/show a code block like it can for other languages. Google also found my "folding mode", but that's based on user-inserted tokens and isn't syntax aware.
0
9583
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9990
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9860
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
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 we have to send another system

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.