This page describes various definitions used in the AveyTense documentation.
See also Python glossary.
abroad object
Object springing from abroad() function.
It is actually an iterable object of internal class AbroadInitializer. To inspect abroad objects, since 0.3.50 there is a class
method ~.Tense.isAbroad().
$k[from] $m[aveytense] $k[import] $t[Tense], $a[d]
$t[Tense].$tm[isAbroad]($a[d]($n[12])) # True
Before 0.3.50, there was need getting the AbroadInitializer class reference via the type constructor:
$k[from] $m[aveytense] $k[import] $a[d]
$f[isinstance]($a[d]($n[12]), $c[type]($a[d]($n[1]))) # True
Constructor of class AbroadInitializer is mysterious, and doesn't require at least one parameter, just as abroad() function:
it demands all 4 from 4 parameters to have a value. First of them is a sequence, last three are corresponding values as in abroad() function,
those are value1, value2 and modifier.
__all__
This attribute can be accessed from many modules and classes, and it returns all non-underscored members of a module or a class. For example, aveytense.__all__
returns all globally scoped functions and classes inside module aveytense, meanwhile
aveytense.Tense.__all__ returns all normally accessible
non-underscored members of the class aveytense.Tense.
There were plans making creation of __all__ attribute easier, however, neither
locals() nor
globals() were helping with this
blueprint. For this concept, there were supposed to be new definitions in submodule
~.util: decorator @~.util.all and inheritable class
~.util.All. Ultimately, both of these definitions have been marked unrealized for version 0.3.41.
AVT_ prefixed types
≥ 0.3.52
Types with AVT_ prefix from submodule aveytense.types are
supposed to be generic and warrant this state for all supported versions of Python by AveyTense (≥ 3.8). Naming syntax is:
$k[AVT_]<typeName> # first letter is uppercased, then rest is CamelCase'd
The AVT_ prefix is used for generic versions of:
classes from collections.abc module.
Due to ambiguous character of Set
(before Python 3.9 type alias for set builtin) it is called Uniqual in AveyTense. Same denomination is used in
MutableSet - MutableUniqual
Types with AVT_ prefix allow to avoid importing typing module along with collections, collections.abc and contextlib for
every Python version preceding 3.8. Example (supported versions of Python by AveyTense):
# from __future__ import annotations
$k[from] $m[aveytense].$msu[types] $k[import] $o[*]
$k[from] $m[typing] $k[import] $c[List]
$k[def] $f[f]($p[i]: $c[l]$c[ist][$c[int]]): $o[...] # ≥ 3.9
$k[def] $f[f]($p[i]: $c[List][$c[int]]): $o[...] # 3.8
$k[def] $f[f]($p[i]: $c[AVT_List][$c[int]]): $o[...] # ≥ 3.8
Note all these type aliases are practically deprecated aliases from the typing Python library
(article)
mode parameter
The mode parameter appears in class methods of class
aveytense.Tense usually starting with is- prefix,
and it is used to modify the checking technique. By default it usually has value ~.constants.MODE_AND, indicating every object must comply specific requirement.
Same can be achieved with value "and". Meanwhile values ~.constants.MODE_OR and "or" allow to alleviate the value checking - at least one
of the objects has to complete the given condition. One of examples is given in class method
~.Tense.hasattr().
Examples of class methods in class aveytense.Tense having the mode parameter:
~.Tense.isEllipsis(),
~.Tense.isInteger(),
~.Tense.isNone(),
~.Tense.isString().
This parameter has been defined on large scale in version 0.3.36, but ~.Tense.hasattr() has it since 0.3.34.
Kind of positional parameters before PEP 570. To create
positional parameters before PEP 570 was accepted in Python 3.8, it was required to use 2 underscores before parameter names, and on the parameter section
beginning only.
$k[def] $f[f]($p[__p1], $p[__p2], $p[__p3] $o[=] $n[84]): $o[...]
Last built-in function in Python, which used this notation, was range.
Perhaps you can actually pass a value with keyword, what makes this type of parameters universal, code actually nudges that these parameters
require a parameter passed via position. It is also worth noticing some libraries and applications use this naming convention as in
this section, including Visual Studio Code.
Pre-PEP 570 positional parameters are included in final properties in class ~.util.ParamVar
starting with the word positional. If there is need to mark these positional parameters as universal, consider following solution:
$k[from] $m[aveytense] $k[import] $o[*]
$f[def] $f[f]($p[__p1], $p[__p2], $p[__p3]): $o[...]
$v[p] $o[=] $msu[util].$cut[ParamVar]($f[f])
$t[Tense].$tm[print]($v[p].$fp[positional] $o[+] $v[p].$fp[universal])
pure functions
This kind of functions return internally modified version of one or more parameter values usually by copying the values to internal variables,
however, without modifying parameter values passed. Examples of pure functions:
~.Tense.append(),
~.Tense.extend(),
~.Tense.reverse(),
~.Tense.shuffle().
Consider the following invocation:
$k[from] $m[random] $k[import] $f[shuffle]
$v[a] $o[=] [$n[72], $n[83], $n[36], $n[48]]
$f[shuffle]($v[a])
$t[Tense].$tm[print]($v[a])
# [48, 72, 83, 36]
If random.shuffle() modified the list instance
(there a), that means this function isn't pure. Meanwhile with ~.Tense.shuffle() returned is reversed copy of the sequence:
$k[from] $m[aveytense] $k[import] $t[Tense]
$v[a] $o[=] [$n[72], $n[83], $n[36], $n[48]]
$v[b] $o[=] $t[Tense].$tm[shuffle]($v[a])
$t[Tense].$tm[print]($v[a], $v[b])
# [72, 83, 36, 48], [48, 72, 83, 36]
Thereupon ~.Tense.shuffle() class method is pure, because it returns modified version of the target sequence.
sequence items type checking functions
This kind of functions are looking not only for specific sequence type, such as
list with
~.Tense.isList() class method or
set with
~.Tense.isSet(),
but also types of all items within the sequence. This is what additional parameter type is for. Some IDEs can type hint a sequence,
just like below:
$v[a] $o[=] [$n[32]] $o[+] [$s[64]] # list[int | str]
However, we cannot really deduce types from all sequence items using
typing.get_args()
with type(a) as this function's value. That means we will have to iterate through all items in the sequence.
$t[Tense].$tm[print]([$c[type]($v[e]) $k[for] $v[e] $k[in] $v[a]])
# [<class 'int'>, <class 'str'>]
This technique is used with the type parameter. For example (order of types there doesn't matter):
$k[from] $m[aveytense] $k[import] $o[*]
$t[Tense].$tm[print]($t[Tense].$tm[isList]($v[a], ($c[int], $c[str])))
# True
Concept with [type(e) for e in <sequence>] promotes defined in version 0.3.51 class method
~.Tense.getAllItemsTypes().
If some types repeat, they won't be added to the returned unique tuple (see
~.util.uniquetuple).
tilde (~)
Documentation-exclusive; refers to aveytense module mostly; also used to keep accordance with tense before 0.3.40. If ~ is used in a class
or module documentation, then it can point to that class/module.
universal parameter
This kind of parameter can be passed either via position or keyword. Placement isn't hard to recognize.
deff(
[(...POSITIONAL_PARAMS, /)|(...PRE_PEP_570_POSITIONAL_PARAMS)],
[...UNIVERSAL_PARAMS],
[*[VARIABLE_ARG]],
[...KEYWORD_PARAMS],
[**VARIABLE_KWARG]
):
Word universal is used in final properties in class ~.util.ParamVar as
their prefix.