Skip to content

Commit

Permalink
python: Expr.__str__() (#2559)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Feb 6, 2022
1 parent 194e402 commit 3e04dba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions py-polars/polars/internals/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class Expr:
def __init__(self) -> None:
self._pyexpr: PyExpr # pragma: no cover

def __str__(self) -> str:
return self._pyexpr.to_str()

def _repr_html_(self) -> str:
return self._pyexpr.to_str()

@staticmethod
def _from_pyexpr(pyexpr: "PyExpr") -> "Expr":
self = Expr.__new__(Expr)
Expand Down
3 changes: 3 additions & 0 deletions py-polars/src/lazy/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ impl<'p> PyObjectProtocol<'p> for PyExpr {

#[pymethods]
impl PyExpr {
pub fn to_str(&self) -> String {
format!("{:?}", self.inner)
}
pub fn eq(&self, other: PyExpr) -> PyExpr {
self.clone().inner.eq(other.inner).into()
}
Expand Down

0 comments on commit 3e04dba

Please sign in to comment.