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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to