@@ -1651,23 +1651,16 @@ def tabulate(
16511651 `colglobalalign` allows for global alignment of columns, before any
16521652 specific override from `colalign`. Possible values are: None
16531653 (defaults according to coltype), "right", "center", "decimal",
1654- "left". Other values are treated as "left".
1654+ "left".
16551655 `colalign` allows for column-wise override starting from left-most
16561656 column. Possible values are: "global" (no override), "right",
1657- "center", "decimal", "left". Other values are teated as "left".
1657+ "center", "decimal", "left".
16581658 `headersglobalalign` allows for global headers alignment, before any
16591659 specific override from `headersalign`. Possible values are: None
1660- (follow columns alignment), "right", "center", "left". Other
1661- values are treated as "right".
1660+ (follow columns alignment), "right", "center", "left".
16621661 `headersalign` allows for header-wise override starting from left-most
16631662 given header. Possible values are: "global" (no override), "same"
1664- (follow column alignment), "right", "center", "left". Other
1665- values are teated as "right".
1666-
1667- Note: if column alignment is illegal (treating it as left) and
1668- corresponding header aligns as "same", it will treat it as "right".
1669- Thus, in spite of "same" being specified, alignment will not
1670- visually be the same in the end.
1663+ (follow column alignment), "right", "center", "left".
16711664
16721665 Table formats
16731666 -------------
@@ -2212,7 +2205,9 @@ def tabulate(
22122205 if colalign is not None :
22132206 assert isinstance (colalign , Iterable )
22142207 for idx , align in enumerate (colalign ):
2215- if align != "global" :
2208+ if not idx < len (aligns ):
2209+ break
2210+ elif align != "global" :
22162211 aligns [idx ] = align
22172212 minwidths = (
22182213 [width_fn (h ) + min_padding for h in headers ] if headers else [0 ] * len (cols )
@@ -2234,9 +2229,11 @@ def tabulate(
22342229 # then specific header alignements
22352230 if headersalign is not None :
22362231 assert isinstance (headersalign , Iterable )
2237- for idx , align in enumerate (headersalign [: len ( aligns_headers )] ):
2232+ for idx , align in enumerate (headersalign ):
22382233 hidx = headers_pad + idx
2239- if align == "same" and hidx < len (aligns ): # same as column align
2234+ if not hidx < len (aligns_headers ):
2235+ break
2236+ elif align == "same" and hidx < len (aligns ): # same as column align
22402237 aligns_headers [hidx ] = aligns [hidx ]
22412238 elif align != "global" :
22422239 aligns_headers [hidx ] = align
0 commit comments