Python missing leading space compare

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanawalt
    Visitor
    • Feb 2008
    • 4

    Python missing leading space compare

    Correct me if I'm wrong, but I think this element should be in the default python file format:
    Leading White Space=Text matching ^\s*[^\s]

    Didn't see this anywhere else in the forum when I searched, but maybe I missed it. The defaults for Python show changes in leading space as unimportant, but as any Python programmer knows that isn't the case.

    Steve
  • Aaron
    Team Scooter
    • Oct 2007
    • 15997

    #2
    Hello,

    We wouldn't want to make the first character match as part of the whitespace. What do you think of:
    ^\s+
    Aaron P Scooter Software

    Comment

    • Chris
      Team Scooter
      • Oct 2007
      • 5538

      #3
      Steve,

      Thank you for pointing out this error in the File Format. We'll have this fixed in our next release of BC3 (3.0.16).
      Chris K Scooter Software

      Comment

      • jdmarch
        Fanatic
        • Oct 2007
        • 143

        #4
        Continuing issue with Python whitespace

        There's still a Python whitespace problem in the current BC version 3.1.4.

        If two lines contain nothing but whitespace and comments, then they should not be considered significantly different from each other, no matter what the indentation level.

        In contrast, BC thinks that leading whitespace differences on lines with no code are important.

        If it were possible to strip all trailing whitespace (including comments) before considering leading whitespace, then all such lines would simply be read as empty, and it seems that this problem would disappear.

        Comment

        • Aaron
          Team Scooter
          • Oct 2007
          • 15997

          #5
          If the whitespace is within the definition of Comment, then it will be considered the level of Importance used for Comment.

          It sounds like you want the Comment to be Important and the whitespace to be Unimportant. In this case, you could delete the definition of Comment and let it use the default Everything Else and Whitespace rules.

          It is on our wishlist to add more whitespace handling to our grammar elements.
          Aaron P Scooter Software

          Comment

          • jdmarch
            Fanatic
            • Oct 2007
            • 143

            #6
            Perhaps I wasn't clear enough in my description of the problem.

            1. The problem occurs even if no comment is involved. The simplest example is that a line with only whitespace is (wrongly) considered to have important differences from an empty line. So an editor which cleans up trailing whitespace can cause BC to see lots of spurious "significant differences."

            2. Actually, I have both comment and white space as not important, which means that all lines containing only whitespace and comments should be only unimportantly different from each other. Yet BC thinks they are not.

            Comment

            • Aaron
              Team Scooter
              • Oct 2007
              • 15997

              #7
              Hello,

              Thanks for the clarification.

              Would you be able to email in your support package (Help menu -> Support; Export) and a pair of sample files to [email protected]

              Please include a link back to this forum post as well.
              Aaron P Scooter Software

              Comment

              • jdmarch
                Fanatic
                • Oct 2007
                • 143

                #8
                Support package and sample files emailed. Thanks.

                Comment

                • Aaron
                  Team Scooter
                  • Oct 2007
                  • 15997

                  #9
                  Thanks.

                  We are looking at making lines with only whitespace a new grammar element:
                  ^\s+$
                  and including optional leading whitespace in the comment definition:
                  \s*# to end of line
                  Aaron P Scooter Software

                  Comment

                  • jdmarch
                    Fanatic
                    • Oct 2007
                    • 143

                    #10
                    Thanks, Aaron, that seems to work -- and now I see how cleanly grammar and importance are specified in BC... nice!

                    Comment

                    Working...