Python Cheatsheets

[BASIC]

[JAVASCRIPT]

Conditional Expressions

Finds conditional expressions of the form '... if ... else ...' where the classes of the sub-expressions differ

[BASIC]

[PYTHON]

Builtin objects

Finds expressions that refer to an object in the builtins module (like int or None).

[BASIC]

[PYTHON]

Call to method

Finds calls to MyClass.methodName

[BASIC]

[PYTHON]

Calls to function

Finds calls to any function named 'len'

[BASIC]

[PYTHON]

Class subclasses

Finds classes that subclass MyClass

[BASIC]

[PYTHON]

Create new object

Finds places where we create a new instanceof `MyClass`

[BASIC]

[PYTHON]

Elif statement

Finds `elif` sub-statements within `if` statements

[BASIC]

[PYTHON]

Empty blocks

Finds the first statement in a block consisting of nothing but Pass statements

[BASIC]

[PYTHON]

Equalities as expression statements

Finds `==` equality expressions that form a statement

[BASIC]

[PYTHON]

Equality test on boolean

Finds tests like `==true`, `==false`, `'!=true`, `is false`

[BASIC]

[PYTHON]

File with given name

Finds files called `spam.py`

[BASIC]

[PYTHON]

Find prints

Find print statements or calls to the builtin function 'print'

[BASIC]

[PYTHON]

Find-references links

Generates use-definition pairs that provide the data for find-references in the code viewer.

[BASIC]

[PYTHON]

Functions with many parameters

Finds functions with more than 7 parameters

[BASIC]

[PYTHON]

Generator functions

Finds generator functions

[BASIC]

[PYTHON]

Handle exception of given class

Finds places where we handle MyExceptionClass exceptions

[BASIC]

[PYTHON]

If statements with empty then branch

Finds 'if' statements where the 'then' branch consists entirely of Pass statements

[BASIC]

[PYTHON]

Integer literal

Finds places where we use the integer literal `0`

[BASIC]

[PYTHON]

Jump-to-definition links

Generates use-definition pairs that provide the data for jump-to-definition in the code viewer.

[BASIC]

[PYTHON]

Mutual recursion

Finds pairs of functions that call each other

[BASIC]

[PYTHON]

Override of method

Finds methods that override MyClass.methodName

[BASIC]

[PYTHON]

Print AST

Outputs a representation of a file's Abstract Syntax Tree. This query is used by the VS Code extension.

[BASIC]

[PYTHON]

Private access

Find accesses to 'private' attributes (those starting with an underscore)

[BASIC]

[PYTHON]

Raise exception of a class

Finds places where we raise AnException or one of its subclasses

[BASIC]

[PYTHON]

Raw string literals

Finds string literals with an 'r' prefix

[BASIC]

[PYTHON]

Recursion

Finds functions that call themselves

[BASIC]

[PYTHON]

Single-quoted string literals

Finds string literals using single quotes

[BASIC]

[PYTHON]

Store None to collection

Finds places where `None` is used as an index when storing to a collection

[BASIC]

[PYTHON]

String conversion expressions

Finds `String conversions` expressions (expressions enclosed in backticks), which are removed in Python 3

[BASIC]

[PYTHON]

TODO comments

Finds comments containing the word 'TODO'

[BASIC]

[PYTHON]

Try-finally statements

Finds try-finally statements without an exception handler