python-hyper/hyperlink

why is str() the same as repr()?

wbolster opened this issue · 3 comments

>>> url = URL.from_text('https://example.org/api/v2')

>>> str(url)
"URL.from_text('https://example.org/api/v2')"

>>> repr(url)
"URL.from_text('https://example.org/api/v2')"

why is str() not just the url?

https://example.org/api/v2

the requests library "stringifies" urls (by design). in practice that means that for instance furl instances can be passed directly. this is not possible with hyperlink:

>>> from hyperlink import URL
>>> import requests

>>> url = URL.from_text('https://example.org/api/v2')
>>> requests.get(url)
[...]
InvalidSchema: No connection adapters were found for 'URL.from_text('https://example.org/api/v2')'

That's a good point, I don't think I'd be opposed to this change. Maybe @Lukasa has an opinion?

Just merged the fix, this will be released soon! Just need #54 and maybe #56 merged and we'll have a brand new hyperlink 18 :)

Thanks again for the issue!

awesome, keep up the good work.