py-appscript manual | 5. Keyword conversion

#

## 5. Keyword conversion

### Keyword conversion

Because application terminology resources specify AppleScript-style keywords for class, property, command, etc. names, appscript uses the following rules to translate these keywords to legal Python identifiers:

- Characters a-z, A-Z, 0-9 and underscores (_) are preserved.
- Spaces, hyphens (-) and forward slashes (/) are replaced with underscores.
- Ampersands (&) are replaced by the word 'and'.
- All other characters are converted to 0x00-style hexadecimal representations.
- Names that match Python keywords or names reserved by appscript have an underscore appended. The following names are reserved by appscript:

      aborttransaction              help
      after                         ID
      AND                           ignore
      any                           isin
      before                        isnotin
      beginning                     last
      beginswith                    middle
      begintransaction              next
      contains                      NOT
      doesnotbeginwith              OR
      doesnotcontain                previous
      doesnotendwith                relaunchmode
      end                           resulttype
      endswith                      timeout
      endtransaction                waitreply
      first

  See Python's `keyword` module for a list of reserved Python keywords.
- Appscript defines default terminology for standard type classes such as `integer` and `unicode_text`, and standard commands such as `open` and `quit`. If an application-defined name matches a built-in name but has a different Apple event code, appscript will append an underscore to the application-defined name.

You can use ASDictionary or appscript's built-in `help` method to export or view application terminology in appscript format. See the Getting Help chapter for more information.