HikariSPEL (Hikari SimPle Expression Language).
HikariSPEL (Hikari SimPle Expression Language) is a super-simple expression language used in this module for quickly mapping values to other values and producing streams of changes. This somewhat mirrors other programming languages like Java which have a proper Stream API.
The concept of HikariSPEL is that you are trying to look at the attribute
of something. So, running
"bar.baz.bork" against an object
foo would be
foo.bar.baz.bork in pure Python. The reason for doing this is
Python lambdas are clunky, and using a nested function is nasty boilerplate.
foo, we assume
bar is an attribute or property
baz is an attribute or property of
foo.bar. We may instead
want to invoke a method that takes no parameters (looking at
an example. To do this, we append
() onto the attribute name. For example,
author.username.islower() to a
All expressions may start with a
.. You can negate the whole expression
by instead starting them with
You may also want to negate a condition. To do this, prepend
attribute name. For example, to check if a message was not made by a bot,
you could run
author.!is_bot on a
Message object. Likewise, to check if
the input was not a number, you could run
This expression language is highly experimental and may change without prior notice for the time being.
- class hikari.internal.spel.AttrGetter(attr_name)[source]#
An attribute getter that can resolve nested attributes and methods.
This follows the SPEL definition for how to define expressions. Expressions may be preceded with an optional
.to aid in readability.