{"record":{"id":"c79c3f4fee241be1","repo":"pola-rs/polars","slug":"separator-must-be-a-single-character-found-sep","errorCode":null,"errorMessage":"`separator` must be a single character; found {separator!r}","messagePattern":"`separator` must be a single character; found (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/config.py","lineNumber":651,"sourceCode":"        ...     thousands_separator=\".\",\n        ...     decimal_separator=\",\",\n        ...     float_precision=3,\n        ... ):\n        ...     print(df)\n        shape: (3, 1)\n        ┌───────────────┐\n        │             v │\n        │           --- │\n        │           f64 │\n        ╞═══════════════╡\n        │     9.876,543 │\n        │ 1.010.101,000 │\n        │  -123.456,780 │\n        └───────────────┘\n        \"\"\"\n        if isinstance(separator, str) and len(separator) != 1:\n            msg = f\"`separator` must be a single character; found {separator!r}\"\n            raise ValueError(msg)\n        plr.set_decimal_separator(sep=separator)\n        return cls\n\n    @classmethod\n    def set_thousands_separator(\n        cls, separator: str | bool | None = None\n    ) -> type[Config]:\n        \"\"\"\n        Set the thousands grouping separator character.\n\n        Parameters\n        ----------\n        separator : str, bool\n            Set True to use the default \",\" (thousands) and \".\" (decimal) separators.\n            Can also set a custom char, or set ``None`` to omit the separator.\n\n        See Also\n        --------","sourceCodeStart":633,"sourceCodeEnd":669,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/config.py#L633-L669","documentation":"Config context's decimal separator setter validates that separator is exactly one character; passing an empty string or multi-character string raises ValueError because it would corrupt numeric formatting.","triggerScenarios":"pl.Config.set_decimal_separator(',') is fine, but set_decimal_separator(', ') or set_decimal_separator('..') raises ValueError.","commonSituations":"Copy-pasting a locale pattern like ', ' or '. '; passing an empty string (len 0 != 1 also fails).","solutions":["Pass exactly one character, e.g. ',' or '.'","Pass None to reset to default","Strip/validate the string before calling"],"exampleFix":"// before\npl.Config.set_decimal_separator(', ')  # ValueError\n// after\npl.Config.set_decimal_separator(',')","handlingStrategy":"validation","validationCode":"assert isinstance(separator, str) and len(separator) == 1, separator","typeGuard":"def is_single_char(s: object) -> bool:\n    return isinstance(s, str) and len(s) == 1","tryCatchPattern":"try:\n    pl.Config.set_decimal_separator(sep)\nexcept ValueError as e:\n    logging.error('%s', e)\n    raise","preventionTips":["Always pass one-character strings or None","Strip whitespace only if the separator itself is not whitespace","Beware locale patterns with trailing spaces"],"tags":["polars","config","formatting"],"backgroundTag":"invalid-argument-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}