pathex.expressions.expression module
Expressions abstract base class
- Module
pathex.expressions.expression
- class Expression[source]
Bases:
abc.ABC
Expressions abstract base class.
In PathEx objects of any other kind different from
Expression
are interpreted as an identity terminal expression.Expression
is meant to grouping those kind of expressions that has a special meaning and to provide general methods and Python operator overloading.- get_eager_generator(self, machine: pathex.generation.machines.machine.Machine | None = None, word_type: type[T] = ListWrapper, complete_words: bool = True) Generator[T, None, None] [source]
Gives a generator of
CollectionWrapper
object that represent the words generated by the expression.This method is meant as a handy shortcut for
words_generator(self, machine, word_type, complete_words)
.machine
is The machine to be used to interpret the expression. If it isNone
then an instance ofExtendedMachineCompalphabet
will be used. Defaults toNone
.word_type
is aCollectionWrapper
subtype that will be the type of collection to be used to represent words. Defaults toListWrapper
.complete_words
is a flag indicating if only complete words are to be given. Defaults toTrue
.
- get_generator(machine: pathex.generation.machines.machine.Machine | None = None) WordsGenerator [source]
Gives a
WordsGenerator
with default values for the actual expression.This method is meant as a handy shortcut for
WordsGenerator(expression, machine)
.machine
is the machine to be used to interpret the expression. If it isNone
then an instance ofExtendedMachineCompalphabet
will be used. Defaults toNone
.
- get_language(language_type: type[T] = SetWrapper, machine: pathex.generation.machines.machine.Machine | None = None, word_type: type[CollectionWrapper] = ListWrapper, complete_words: bool = True) T [source]
Gives a
CollectionWrapper
object that containsCollectionWrapper
objects that represent the words generated by the expression.language_type
is a subtype ofCollectionWrapper
that will be used as the type of the object to be returned. Defaults toSetWrapper
.machine
is the machine to be used to interpret the expression. If it isNone
then an instance ofExtendedMachineCompalphabet
will be used. Defaults toNone
.word_type
is aCollectionWrapper
subtype that will be the type of collection to be used to represent words. Defaults toListWrapper
.complete_words
is a flag indicating if only complete words are to be given. Defaults toTrue
.