Skip to content

Aleatoryous (Python object)

Diego Ramirez edited this page May 11, 2021 · 3 revisions

The Aleatoryous object from aleat3

"Aleatoryous" is also the name of the aleat3 object, used for building the aleatory objects. Let's take a view on it.

Object analysis

class Aleatoryous(self, mode="random", extras=None)

Generates an aleatory object. Its methods will return aleatory results, following the syntax defined on mode. This parameter could be:

  • "aleatory.coin": Coin syntax, returns "Head" or "Tails" (Python strings).
  • "aleatory.dice": Dice results, from 1 to 6.
  • "aleatory.roulette": Roulette syntax. Selects from a custom sequence defined in extras.
  • "random": Default option. Replaced on the __init__ by one of the other options.

About the 'random' mode

The random mode only reacts on the __init__, but then it only uses the assigned mode. For example:

a = Aleatoryous("random", my_optional_seq)

will set the mode to a random mode (could be "aleatory.dice", "aleatory.coin" or "aleatory.roulette"), and the argument mode becomes that new mode. The string "random" is deleted.

Object Methods

The Aleatoryous instances have the methods:

Aleatoryous.single()

Returns only one result, following the actual syntax.

Aleatoryous.first_*()

Aleatoryous.first_5()
Aleatoryous.first_10()
Aleatoryous.first_50()
Aleatoryous.first_100()
Aleatoryous.first_given(times, repeat=True)

Return a Python list with aleatory results (according to the defined syntax).

In the case of first_given(), you must enter the times you want to append to the destination list. When repeat is False, the results won't be repeated on the list (only available on modes dice and roulette).

Aleatoryous.getmode()

Returns the assigned mode (for example: if you are using the dice syntax, "aleatory.dice").

Aleatoryous.changemode(mode, extras=None)

This method calls the object __init__ once again, commonly to change the syntax mode or modify the sequence to loop (in the case of the roulette mode).

Use this wiki to find a wide and free description of some terms for this package: aleat3. Hope you'll enjoy it! If you want, sign in and create a wiki page now!

🛠️ with ❤️ by Diego Ramirez.

Clone this wiki locally