You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/12/01 05:22:38 UTC
[GitHub] [spark] zhengruifeng commented on a diff in pull request #38858: [SPARK-41346][CONNECT][PYTHON] Implement `asc` and `desc` functions
zhengruifeng commented on code in PR #38858:
URL: https://github.com/apache/spark/pull/38858#discussion_r1036701948
##########
python/pyspark/sql/connect/column.py:
##########
@@ -84,7 +85,7 @@ def __init__(self) -> None:
def to_plan(self, session: "SparkConnectClient") -> "proto.Expression":
...
- def __str__(self) -> str:
+ def __repr__(self) -> str:
Review Comment:
a simple example for why we should use `__repr__`:
```
In [20]: class A:
...: def __str__(self) -> str:
...: return "123"
...:
In [21]: a = A()
In [22]: a
Out[22]: <__main__.A at 0x1034bef40>
In [23]: str(a)
Out[23]: '123'
In [24]: repr(a)
Out[24]: '<__main__.A object at 0x1034bef40>'
In [30]: class A:
...: def __repr__(self) -> str:
...: return "123"
...:
In [31]: a = A()
In [32]: a
Out[32]: 123
In [33]: str(a)
Out[33]: '123'
In [34]: repr(a)
Out[34]: '123'
In [35]: class A:
...: def __str__(self) -> str:
...: return "123"
...: def __repr__(self) -> str:
...: return "xyz"
...:
In [36]: a = A()
In [37]: a
Out[37]: xyz
In [38]: str(a)
Out[38]: '123'
In [39]: repr(a)
Out[39]: 'xyz'
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org