Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use slice notation on URI's for authentication creds #10

Closed
ptmcg opened this issue Feb 6, 2019 · 3 comments
Closed

Use slice notation on URI's for authentication creds #10

ptmcg opened this issue Feb 6, 2019 · 3 comments

Comments

@ptmcg
Copy link

ptmcg commented Feb 6, 2019

While on the topic of operator overloading on the SO Python chat, I got the idea after chatting with @amcgregor that adding a slice notation to a URI would be a nice extension of this embedded DSL syntax:

Example:

url = URI["username":"password"]

This would be easy and intuitive in interactive sessions, without extra API namespace clutter.

@amcgregor
Copy link
Member

Experimenting in a REPL, I was dubious about the use of colon notation, however, apparently, slice() is a honey-badger and doesn't care that the "indexes" are non-numeric. Yay!

class Foo:
	def __getitem__(self, item): return item

Foo()["username":"password"].start == "username"

@amcgregor
Copy link
Member

In the process of implementing, use of slices this way will return a new URI instance and will not mutate the original. Isolation of this behaviour to slices preserves existing mapping behaviour of URIs to their query string components.

@amcgregor
Copy link
Member

Feature merged. Will be present in next release. As a note, the next release will be the final release supporting Python 2.

@amcgregor amcgregor added this to the 2.0.2 Feature Release milestone May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants