question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider changing __repr__ for Arrow

See original GitHub issue

Here are the current str and repr methods for Arrow.

(arrow) chris@ThinkPad:~/arrow$ python
Python 3.8.3 (default, Jul  7 2020, 18:57:36) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> dt=arrow.utcnow()
>>> str(dt)
'2020-07-27T22:38:46.653869+00:00'
>>> print(dt)
2020-07-27T22:38:46.653869+00:00
>>> repr(dt)
'<Arrow [2020-07-27T22:38:46.653869+00:00]>'

__str__ should be human readable which I think is achieved, however __repr__ is designed for debugging and therefore needs to be explicit. It’s also nice (but not required) if the __repr__ can be instantiated into a new object.

This would be a breaking change so fits well for 1.0.0 if we decide to do it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jadchaarcommented, Nov 9, 2020

We should aim for a __repr__ similar to that of datetime: https://stackoverflow.com/a/19597196/3820660.

1reaction
systemcatchcommented, Nov 10, 2020

How about this?

>>> repr(dt)
arrow.Arrow(2020, 7, 27, 22, 38, 46, 653869, tzinfo=tzutc())
Read more comments on GitHub >

github_iconTop Results From Across the Web

Alter the width of an annotate arrow in matplotlib
The easiest way to do this will be by using FancyBboxPatch with the darrow (double arrow) option. The one tricky part of this...
Read more >
arrow/types.pxi at master · apache/arrow - GitHub
Apache Arrow is a multi-language toolbox for accelerated data interchange and in-memory processing ... return fmt.format(self, repr(self.storage_type)).
Read more >
What I Learned at Work this Week: Python Arrow Library (and ...
Change the language of our timestamp. Arrow can work with various data types (date, time, datetime, tzinfo, timedelta, relativedelta, etc.) and can parse...
Read more >
Use Apache Arrow to Assist PySpark in Data Processing
This article looks into how you can use Apache Arrow to Assist PySark in data processing operations and also discusses Apache Arrow and...
Read more >
Apache Arrow 5.0.0 Release
Apache Arrow 5.0.0 (29 July 2021) This is a major release covering more ... ARROW-10316 - [Python] Consider using __wrapped__ for compute ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found