File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,17 @@ class TableToAscii:
1111 """Class used to convert a 2D Python table to ASCII text"""
1212
1313 def __init__ (self , header_row : List , body : List [List ], footer_row : List ):
14+ """Validate arguments and initialize fields"""
15+ # check that values are valid
16+ if len (header_row ) != len (footer_row ):
17+ raise ValueError ("header row and footer row must have the same length" )
18+ if len (header_row ) != len (body [0 ]):
19+ raise ValueError ("header row and body rows must have the same length" )
20+ for row in body [1 :]:
21+ if len (body [0 ]) != len (row ):
22+ raise ValueError ("all rows in body must have the same length" )
23+
24+ # initialize fields
1425 self .__header_row = header_row
1526 self .__body = body
1627 self .__footer_row = footer_row
You can’t perform that action at this time.
0 commit comments