Skip to content

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

Closed
@wbolster

Description

@wbolster
>>> 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')'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions