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.

Clarify how to encode parameters in the Python bindings

See original GitHub issue

We got a report form a user that they had trouble with https://zulip.com/api/get-subscriptions, because they tried:

client.get_subscriptions(include_subscribers=True)

and got an exception. The actual way to pass that parameter is:

client.get_subscriptions(dict(include_subscribers=True))

i.e. pass the parameters as a dictionary, rather than as arguments to this function. I think the user was very reasonable in being confused by this, since we don’t say clearly anywhere on that page how to encode that detail in the Python bindings.

We should figure out how to either document this or adjust API endpoints like this one to pass their kwards are parameters.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
anderskcommented, Nov 11, 2020

Use the same rule the dict function itself uses, which is that the kwargs take precedence:

>>> dict({"include_subscribers": False}, include_subscribers=True)
{'include_subscribers': True}

And we can just deprecate the non-kwargs way, since it can be replaced with client.list_subscriptions(**some_dict).

0reactions
neiljpcommented, Nov 11, 2020

As long as there’s no conflict between the specific request parameters and the general options, this seems reasonable to allow, though we’d have to resolve (or document) the case of which takes precedence if specifying parameters both ways.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I percent-encode URL parameters in Python?
@chrizonline Just use urllib.parse.quote(url, safe=':/') . Even better, encode some path , then join strings. This is ...
Read more >
Python Strings encode() method - GeeksforGeeks
Parameters : encoding: Specifies the encoding on the basis of which encoding has to be performed. errors: Decides how to handle the errors...
Read more >
codecs — Codec registry and base classes — Python 3.11.1 ...
This module defines base classes for standard Python codecs (encoders and decoders) and provides access to the internal Python codec registry, which manages...
Read more >
Comma encoding in request params · Issue #794 - GitHub
I'm making requests against an API which takes comma separated parameter values. A working request looks like this: curl http://localhost:4444/endpoint?val= ...
Read more >
Percent-encoding - Wikipedia
Percent-encoding, also known as URL encoding, is a method to encode arbitrary data in a Uniform Resource Identifier (URI) using only the limited...
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