str2d.Str2D.strip2d

Str2D.strip2d(char=' ') Str2D[source]

Strip the data 2-dimensionally. This method checks how much it can trim from each side of the data before it reaches a non-matching character. It then trims the data accordingly.

Parameters:

char (str, optional) – The character to strip, by default ‘ ‘. This is the character that will be trimmed from the data.

Returns:

A new Str2D object with the data stripped.

Return type:

Str2D

Examples

Let’s create an instance of Str2D and assign it to the variable a and then strip the data.

from str2d import Str2D

a = Str2D('''\
............
...xxxxxxx..
...xxxxxxx..
...xxxxxxx..
............
............
''')

Striping ‘.’ from the data will leave just the core of ‘x’s.

a.strip2d(char='.')
xxxxxxx
xxxxxxx
xxxxxxx