Skip to main content

Python

Scopes

Below are visualizations of all our scope tests for this language. These were created primarily for testing purposes rather than as documentation. There are quite a few, and they may feel a bit overwhelming from a documentation standpoint.

Anonymous function

1. Anonymous function

An anonymous function, eg a lambda function, an arrow function, etc.

Argument list

1. Argument list: Actual constructor empty

An empty list of arguments in a constructor call. Insertion delimiter should be empty.

2. Argument list: Actual constructor multi line

A multi line list of arguments in a constructor call. Insertion delimiter should include new line.

3. Argument list: Actual constructor single line

A single line list of arguments in a constructor call

4. Argument list: Actual empty

An empty list of arguments in a function call. Insertion delimiter should be empty.

5. Argument list: Actual method empty

An empty list of arguments in a method call. Insertion delimiter should be empty.

6. Argument list: Actual method multi line

A multi line list of arguments in a method call. Insertion delimiter should include new line.

7. Argument list: Actual method single line

A single line list of arguments in a method call

8. Argument list: Actual multi line

A multi line list of arguments in a function call. Insertion delimiter should include new line.

9. Argument list: Actual single line

A single line list of arguments in a function call

10. Argument list: Formal constructor empty

An empty list of parameters in a constructor declaration. Insertion delimiter should be empty.

11. Argument list: Formal constructor multi line

A multi line list of parameters in a constructor declaration. Insertion delimiter should include new line.

12. Argument list: Formal constructor single line

A single line list of parameters in a constructor declaration

13. Argument list: Formal empty

An empty list of parameters in a function declaration. Insertion delimiter should be empty.

14. Argument list: Formal lambda empty

An empty list of parameters in a lambda declaration. Insertion delimiter should be empty.

15. Argument list: Formal lambda single line

A single line list of parameters in a lambda declaration

16. Argument list: Formal method empty

An empty list of parameters in a class method declaration. Insertion delimiter should be empty.

17. Argument list: Formal method multi line

A multi line list of parameters in a class method declaration. Insertion delimiter should include new line.

18. Argument list: Formal method single line

A single line list of parameters in a class method declaration

19. Argument list: Formal multi line

A multi line list of parameters in a function declaration. Insertion delimiter should include new line.

20. Argument list: Formal single line

A single line list of parameters in a function declaration

Argument or parameter

1. Argument: Actual constructor multi line

A multi line argument in a constructor call. Insertion delimiter should include new line.

2. Argument: Actual constructor single line

A single line argument in a constructor call

3. Argument: Actual method multi line

A multi line argument in a method call. Insertion delimiter should include new line.

4. Argument: Actual method single line

A single line argument in a method call

5. Argument: Actual multi line

A multiline argument in a function call. Insertion delimiter should include new line.

6. Argument: Actual single line

A single line argument in a function call

7. Argument: Catch

A parameter in a catch clause

8. Argument: Formal constructor multi line

A multi line parameter in a constructor declaration. Insertion delimiter should include new line.

9. Argument: Formal constructor single line

A single line parameter in a constructor declaration

10. Argument: Formal lambda single line

A single line parameter in a lambda declaration

11. Argument: Formal method multi line

A multi line parameter in a class method declaration. Insertion delimiter should include new line.

12. Argument: Formal method single line

A single line parameter in a class method declaration

13. Argument: Formal multi line

A multi line parameter in a function declaration. Insertion delimiter should include new line.

14. Argument: Formal single line

A single line parameter in a function declaration

15. Argument: Actual (iteration)

Iteration scope for arguments in a function call: the argument list. The domain should be the entire function call.

16. Argument: Actual constructor (iteration)

Iteration scope for arguments in a constructor call: the argument list. The domain should be the entire constructor call..

17. Argument: Actual method (iteration)

Iteration scope for arguments in a method call: the argument list. The domain should be the entire method call..

18. Argument: Formal (iteration)

Iteration scope for formal parameters in a function declaration: the parameters list. The domain should be the entire function.

19. Argument: Formal constructor (iteration)

Iteration scope for formal parameters in a constructor declaration: the parameter list. The domain should be the entire constructor.

20. Argument: Formal lambda (iteration)

Iteration scope for formal parameters in a lambda declaration: the parameter list. The domain should be the entire lambda.

21. Argument: Formal method (iteration)

Iteration scope for formal parameters in a method declaration: the parameter list. The domain should be the entire method.

Branch

1. Branch: If

An if branch

2. Branch: If elif else

An if-elif-else branch. The removal range for the if branch should include the trailing `else` keyword.

3. Branch: If else

An if-else branch

4. Branch: Loop

A for / while loop branch. For most languages this is not supported, but eg in Python you can have an else branch for a loop.

5. Branch: Switch case

A case/default branch in a switch statement

6. Branch: Ternary

A branch in a ternary expression

7. Branch: Try

A try/catch/finally branch

8. Branch: If (iteration)

Iteration scope for if/elif/else branches: the if-else statement.

9. Branch: Loop (iteration)

Iteration scope for loop branches: the loop statement.

10. Branch: Switch case (iteration)

Iteration scope for switch branches: the switch statement body.

11. Branch: Ternary (iteration)

Iteration scope for ternary expression branches: the ternary expression.

12. Branch: Try (iteration)

Iteration scope for try/catch/finally branches: the try-catch statement.

Class

1. Class

A class in an object-oriented language

2. Class (iteration document)

Iteration scope for classes: the entire document including leading and trailing empty lines.

Collection item

1. Collection item: Unenclosed single line

An item in a comma-separated single line list without enclosing delimiters. This could be multi-variable declarations, import statements, etc.

2. Collection item: Unenclosed (iteration)

Iteration scope for items in a comma-separated list without enclosing delimiters

Collection key

1. Key: Map pair

Key (LHS) of a key-value pair of a map

2. Key: Map pair (iteration)

Iteration scope for keys of key-value pairs in a map: should be between the braces.

Comment

1. Comment: Line

A line comment

Condition

1. Condition: If

A condition in an if statement

2. Condition: Switch case

A condition in a switch statement

3. Condition: Ternary

A condition in a ternary expression

4. Condition: While

A condition in a while loop

5. Condition: Switch case (iteration)

Iteration scope for conditions in a switch statement: the switch statement body.

Function call

1. Function call

A function call

2. Function call: Chain

A chain of function calls, eg `foo().bar()`

3. Function call: Constructor

A constructor call

4. Function call: Method

A method call

Function callee

1. Function callee

The function being called in a function call

2. Function callee: Chain

The function being called in a chain of function calls, including parent objects.

3. Function callee: Constructor

The class being constructed in a class instantiation, including the `new` keyword.

4. Function callee: Method

The function being called in a method call, including parent objects.

If statement

1. If statement

An if statement

Interior

1. Interior: Class

The body of a class

2. Interior: Constructor

The body of a constructor declaration

3. Interior: Foreach

The body of a for-each loop

4. Interior: Function

The body of a function declaration

5. Interior: If

The body of an if/elif/else branch

6. Interior: Method

The body of a method declaration

7. Interior: Resource

the body of a 'with' / 'use' / 'using' statement

8. Interior: Switch

The body of a switch statement

9. Interior: Switch case

The body of a switch case branch

10. Interior: Ternary

The body of a ternary condition/branch

11. Interior: Try

The body of a try/catch/finally branch

12. Interior: While

The body of a while loop

List

1. List

A list/array

Map

1. Map

A map/dictionary

Name

1. Name: Argument actual

Name of a (keyword) argument in a function call

2. Name: Argument catch

Name of a parameter in a catch clause

3. Name: Argument formal

Name of a parameter in a function declaration

4. Name: Argument formal constructor

The name of a parameter in a constructor declaration

5. Name: Argument formal method

Name of a parameter in a class method declaration

6. Name: Assignment

Name (LHS) of an assignment

7. Name: Assignment pattern

LHS of an assignment with pattern destructuring

8. Name: Class

Name of a class

9. Name: Constructor

Name of a constructor

10. Name: Field class

Name (LHS) of a field in a class

11. Name: Foreach

Iteration variable name in a for each loop

12. Name: Function

Name of a function

13. Name: Method

Name of a class method

14. Name: Resource

Name in a 'with' / 'use' / 'using' statement

15. Name: Variable

Name (LHS) of a variable declaration

16. Name: Variable pattern

Name (LHS) of a variable declaration with pattern destructuring

17. Name (iteration block)

Iteration scope for names: statement blocks (body of functions/if-statements/for-loops/etc).

18. Name (iteration class)

Iteration scope for names: class bodies.

19. Name (iteration document)

Iteration scope for names: the entire document including leading and trailing empty lines.

20. Name: Argument actual (iteration)

Iteration scope for names of (keyword) arguments in a function call: the argument list..

21. Name: Argument formal (iteration)

Iteration scope for names of formal parameters in a function declaration: the parameters list. The domain should be the entire function.

22. Name: Argument formal constructor (iteration)

Iteration scope for names of formal parameters in a constructor declaration: the parameters list. The domain should be the entire constructor.

23. Name: Argument formal method (iteration)

Iteration scope for names of formal parameters in a method declaration: the parameters list. The domain should be the entire method.

24. Name: Resource (iteration)

Iteration scope for names in a 'with' / 'use' / 'using' statement: the resource list. The domain should be the entire statement.

Named function

1. Named function

A named function declaration

2. Named function: Constructor

A constructor declaration in a class

3. Named function: Method

A named method declaration in a class

4. Named function (iteration class)

Iteration scope for named functions: class bodies.

5. Named function (iteration document)

Iteration scope for named functions: the entire document including leading and trailing empty lines.

Statement

1. Statement: Assignment

An assignment statement

2. Statement: Break

A break statement

3. Statement: Class

A class declaration

4. Statement: Constructor

A constructor declaration

5. Statement: Continue

A continue statement

6. Statement: Field class

A field declaration in a class

7. Statement: Foreach

A for-each loop statement

8. Statement: Function

A named function declaration

9. Statement: If

A if/elif/else statement

10. Statement: Method

A method declaration

11. Statement: Resource

A 'with' / 'use' / 'using' statement

12. Statement: Return

A return statement

13. Statement: Switch

A switch statement

14. Statement: Try

A try/catch/finally statement

15. Statement: Variable

A variable declaration

16. Statement: While

A while loop statement

17. Statement: Yield

A yield statement

18. Statement (iteration block)

Iteration scope for statements: statement blocks (body of functions/if-statements/for-loops/etc).

19. Statement (iteration class)

Iteration scope for statements: class bodies.

20. Statement (iteration document)

Iteration scope for statements: the entire document including leading and trailing empty lines.

String

1. String: Multi line

A multi-line string

2. String: Single line

A single-line string

Type

1. Type: Argument catch

Type of parameter in a catch clause

2. Type: Argument formal

Type of formal parameter in a function declaration

3. Type: Argument formal constructor

Type of formal parameter in a constructor declaration

4. Type: Argument formal method

Type of formal parameter in a class method declaration

5. Type: Class

A class declaration

6. Type: Field class

Type of field in a class

7. Type: Return

Type of return value in a function declaration

8. Type: Type argument

Type argument to a generic / parametrized type

9. Type: Variable

Type of variable in a variable declaration

10. Type (iteration block)

Iteration scope for types: statement blocks (body of functions/if-statements/for-loops/etc).

11. Type (iteration class)

Iteration scope for types: class bodies.

12. Type (iteration document)

Iteration scope for types: the entire document including leading and trailing empty lines.

13. Type: Argument formal (iteration)

Iteration scope for types of formal parameters in a function declaration: the parameters list. The domain should be the entire function.

14. Type: Argument formal constructor (iteration)

Iteration scope for types of formal parameters in a constructor declaration: the parameters list. The domain should be the entire constructor.

15. Type: Argument formal method (iteration)

Iteration scope for types of formal parameters in a method declaration: the parameters list. The domain should be the entire method.

16. Type: Type argument (iteration)

Iteration scope for type arguments to a generic / parametrized type: the type argument list.

Value

1. Value: Argument actual

The value of a (keyword) argument in a function call

2. Value: Argument formal

The value of a (keyword) argument in a function declaration

3. Value: Argument formal constructor

The value of a parameter in a constructor declaration

4. Value: Argument formal method

The value of a parameter in a class method declaration

5. Value: Assignment

Value (RHS) of an assignment

6. Value: Field class

Value (RHS) of a field in a class

7. Value: Foreach

Iterable in a for each loop

8. Value: Map pair

Value (RHS) of a key-value pair in a map

9. Value: Resource

Value of a 'with' / 'use' / 'using' statement

10. Value: Return

Return value of a function

11. Value: Return lambda

Implicit return value from a lambda

12. Value: Switch

The value / subject of a switch statement

13. Value: Variable

Value (RHS) of a variable declaration

14. Value: Variable pattern

Value (RHS) of a variable declaration with pattern destructuring

15. Value: Yield

Value of a yield statement

16. Value (iteration block)

Iteration scope for values: statement blocks (body of functions/if-statements/for-loops/etc).

17. Value (iteration class)

Iteration scope for values: class bodies.

18. Value (iteration document)

Iteration scope for values: the entire document including leading and trailing empty lines.

19. Value: Argument actual (iteration)

Iteration scope for values of (keyword) arguments in a function call: the arguments list..

20. Value: Argument formal (iteration)

Iteration scope for values of formal parameters in a function declaration: the parameters list. The domain should be the entire function.

21. Value: Argument formal constructor (iteration)

Iteration scope for values of formal parameters in a constructor declaration: the parameters list. The domain should be the entire constructor.

22. Value: Argument formal method (iteration)

Iteration scope for values of formal parameters in a method declaration: the parameters list. The domain should be the entire method.

23. Value: Map pair (iteration)

Iteration scope for values of key-value pairs in a map: should be between the braces.

24. Value: Resource (iteration)

Iteration scope for values in a 'with' / 'use' / 'using' statement: the resource list. The domain should be the entire statement.

Internal scopes

The following are internal scopes. They are not intended for user interaction or spoken use. These scopes exist solely for internal Cursorless functionality.

Disqualify delimiter

1. Disqualify delimiter

Used to disqualify a token from being treated as a surrounding pair delimiter. This will usually be operators containing `>` or `<`, eg `<`, `<=`, `->`, etc

Pair delimiter

1. Pair delimiter

A pair delimiter, eg parentheses, brackets, braces, quotes, etc

Text fragment

1. Text fragment: Comment line

Text fragment consisting of a line comment

2. Text fragment: String multi line

Text fragment consisting of a multi-line string

3. Text fragment: String single line

Text fragment consisting of a single-line string