Get an accessor to the column colname. This method returns a Column instance (see :ref:`ColumnClassDescr`) if the requested column is not nested, and a Cols instance (see :ref:`ColsClassDescr`) if it is. You may use full column pathnames in colname. Calling
(self, colname: str)
| 3316 | return len(self._v_colnames) |
| 3317 | |
| 3318 | def _f_col(self, colname: str) -> Cols: |
| 3319 | """Get an accessor to the column colname. |
| 3320 | |
| 3321 | This method returns a Column instance (see :ref:`ColumnClassDescr`) if |
| 3322 | the requested column is not nested, and a Cols instance (see |
| 3323 | :ref:`ColsClassDescr`) if it is. You may use full column pathnames in |
| 3324 | colname. |
| 3325 | |
| 3326 | Calling cols._f_col('col1/col2') is equivalent to using cols.col1.col2. |
| 3327 | However, the first syntax is more intended for programmatic use. It is |
| 3328 | also better if you want to access columns with names that are not valid |
| 3329 | Python identifiers. |
| 3330 | |
| 3331 | """ |
| 3332 | if not isinstance(colname, str): |
| 3333 | raise TypeError( |
| 3334 | f"Parameter can only be an string. You passed object: " |
| 3335 | f"{colname}" |
| 3336 | ) |
| 3337 | if ( |
| 3338 | colname.find("/") > -1 and colname not in self._v_colpathnames |
| 3339 | ) and colname not in self._v_colnames: |
| 3340 | raise KeyError( |
| 3341 | f"Cols accessor " |
| 3342 | f"``{self._v__tablePath}.cols{self._v_desc._v_pathname}`` " |
| 3343 | f"does not have a column named ``{colname}``" |
| 3344 | ) |
| 3345 | |
| 3346 | return self._g_col(colname) |
| 3347 | |
| 3348 | def _g_col(self, colname: str) -> Cols: |
| 3349 | """Like `self._f_col()` but it does not check arguments.""" |