Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

(ada-python): add pathlibs Path object style as opposed to os-like style. #748

Rykarix started this conversation in Ideas
Discussion options

Hey folks

I was going through your docs here: https://ada-url.readthedocs.io/en/latest/ and couldn't help but think it would be cool if the URL class had support for Path-like "notation" (from pathlib import Path)

For example, instead of having to do this:

from ada_url import join_url
base_url = 'http://a/b/c/d;p?q'
join_url(base_url, '../g')

This could be handled simply by the base class:

from ada_url import URL
base_url = URL("http://example.com")
about_url = base_url / "about"

The output of about_url should be: http://example.com/about, the class itself handles the compliance based consistencies & things like stripping / joining of "/" strings etc

Just like pathlibs Path obejects.

This could probably also be extended by allowing queries, searches and other api-like url structures to be handled by other operators "&" and "|" for eg

This also get's people used to the idea of working with a URL object, which is typically more helpful when encouraging people to conform to some kind of compliance as it lends itself better to more pythonic code & easier typing

You must be logged in to vote

Replies: 2 comments

Comment options

Sounds like a good idea. We can support both of them.

You must be logged in to vote
0 replies
Comment options

Here is a branch to test out.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /