Loading ...
Sorry, an error occurred while loading the content.

57Python mode & module level functions

Expand Messages
  • Ben Gollmer
    Nov 5 7:17 PM
    • 0 Attachment

      I have a number of Python files which contain classes as well as
      module-level functions. Unfortunately the Python mode is unable to
      distinguish between functions which are members of a class and those
      that are not. This makes the function popup rather misleading (see
      screenshot 1, rtrim() and the following functions are not members of
      class ZertHd).

      I used Python's whitespace requirements to hack around this. Replace
      the Defs symbol in RegexSymbols.xml with these two symbols:

      <symbol id="Defs" image="SymbolM" indentation="0" ignoreblocks="yes">
      <regex>^def[ \t]+([\w\d_]+)[ \t]*\([^\)]*\)[ \t]*:</regex>

      <symbol id="Defs" image="SymbolM" indentation="1" ignoreblocks="yes">
      <regex>(?<=[\n\r]|^)[ \t]+def[ \t]+([\w\d_]+)[ \t]*\([^\)]*\)
      [ \t]*:</regex>

      And you will get something that looks like screenshot 2. It is clear
      that rtrim() and the following functions are not in the ZertHd class.
      This might be too hacky to make in into the regular distribution, but
      hopefully someone will find it useful :)

    • Show all 2 messages in this topic