code folding, a unique problem to python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Salerno

    #1

    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? :)
  • Tim Chase

    #2
    Re: code folding, a unique problem to python?

    > But my question is more general: is it possible to implement[color=blue]
    > 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?[/color]

    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. ;)
    [color=blue]
    > 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? :)[/color]

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

    -tkc




    Comment

    • Laszlo Nagy

      #3
      Re: code folding, a unique problem to python?

      John Salerno írta:[color=blue]
      > 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? :)
      >[/color]

      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:




      Best,

      Laszlo

      Comment

      • Fredrik Lundh

        #4
        Re: code folding, a unique problem to python?

        John Salerno wrote:
        [color=blue]
        > 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?[/color]

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

        </F>

        Comment

        • Diez B. Roggisch

          #5
          Re: code folding, a unique problem to python?

          John Salerno schrieb:[color=blue]
          > 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? :)[/color]

          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

          Comment

          • John Salerno

            #6
            Re: code folding, a unique problem to python?

            Fredrik Lundh wrote:[color=blue]
            > John Salerno wrote:
            >[color=green]
            >> 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?[/color]
            >
            > since the Python syntax *has* real block delimiters (look up INDENT and
            > DEDENT in the language reference), it's an editor issue.
            >
            > </F>
            >[/color]

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

            Thanks!

            Comment

            • John Salerno

              #7
              Re: code folding, a unique problem to python?

              Diez B. Roggisch wrote:
              [color=blue]
              > 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.[/color]

              ::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.

              Comment

              • Jarek Zgoda

                #8
                Re: code folding, a unique problem to python?

                John Salerno napisa³(a):
                [color=blue]
                > ::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.[/color]

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

                --
                Jarek Zgoda

                Comment

                • BartlebyScrivener

                  #9
                  Re: code folding, a unique problem to python?

                  Komodo code folds Python, Perl, PHP . . .

                  Comment

                  • Paul McGuire

                    #10
                    Re: code folding, a unique problem to python?


                    "John Salerno" <johnjsal@NOSPA Mgmail.com> wrote in message
                    news:jxfkg.2314 $No6.48555@news .tufts.edu...[color=blue]
                    > 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? :)[/color]


                    Comment

                    • Paul McGuire

                      #11
                      Re: code folding, a unique problem to python?

                      "John Salerno" <johnjsal@NOSPA Mgmail.com> wrote in message
                      news:jxfkg.2314 $No6.48555@news .tufts.edu...[color=blue]
                      >
                      > But my question is more general: is it possible to implement code
                      > folding with Python given that it has no real block delimiters?[/color]

                      SciTE can fold Python.


                      Comment

                      • Grant Edwards

                        #12
                        Re: code folding, a unique problem to python?

                        On 2006-06-15, Paul McGuire <ptmcg@austin.r r._bogus_.com> wrote:[color=blue]
                        > "John Salerno" <johnjsal@NOSPA Mgmail.com> wrote in message
                        > news:jxfkg.2314 $No6.48555@news .tufts.edu...[color=green]
                        >>
                        >> But my question is more general: is it possible to implement code
                        >> folding with Python given that it has no real block delimiters?[/color]
                        >
                        > SciTE can fold Python.[/color]

                        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

                        Comment

                        • SuperHik

                          #13
                          Re: code folding, a unique problem to python?

                          BartlebyScriven er wrote:[color=blue]
                          > Komodo code folds Python, Perl, PHP . . .[/color]

                          also the free ActivePython's Pythonwin IDE

                          Comment

                          • Jarek Zgoda

                            #14
                            Re: code folding, a unique problem to python?

                            Paul McGuire napisa³(a):
                            [color=blue][color=green]
                            >>But my question is more general: is it possible to implement code
                            >>folding with Python given that it has no real block delimiters?[/color]
                            >
                            > SciTE can fold Python.[/color]

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

                            --
                            Jarek Zgoda

                            Comment

                            • jussij@zeusedit.com

                              #15
                              Re: code folding, a unique problem to python?

                              John Salerno wrote:
                              [color=blue]
                              > But my question is more general: is it possible to
                              > implement code folding with Python given that it has
                              > no real block delimiters?[/color]

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

                              A powerful, feature packed, fully configurable IDE specifically designed for Windows developers....


                              Jussi Jumppanen
                              Author: Zeus For Windows IDE

                              Comment

                              Working...