str2d.Str2D.__mul__
- Str2D.__mul__(other: int) Str2D [source]
It doesn’t make sense to multiply a Str2D object by another Str2D object. However, we can multiply a Str2D object by an integer. This will repeat the data equal to the integer value. The direction of the repetition is determined by the side of the Str2D object that the integer is on. If the integer is on the left side, the data will be repeated vertically. If the integer is on the right side, the data will be repeated horizontally.
- Parameters:
other (int) – The number of times to repeat the data.
- Returns:
A new Str2D object with the repeated data.
- Return type:
Examples
Let’s create an instance of Str2D and assign it to the variable a.
from str2d import Str2D a = Str2D('a b c d\ne f g\nh i\nj')
We can multiply the data by multiplying by an integer on the right side.
a * 2
a b c da b c d e f g e f g h i h i j j
We can also multiply the data by multiplying by an integer on the left side.
2 * a
a b c d e f g h i j a b c d e f g h i j