Skip to content

ipfsApi.Client should use defaults when given None as a value #7

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

Closed
larsks opened this issue Sep 10, 2015 · 0 comments
Closed

ipfsApi.Client should use defaults when given None as a value #7

larsks opened this issue Sep 10, 2015 · 0 comments

Comments

@larsks
Copy link
Contributor

larsks commented Sep 10, 2015

When host, port, or base is None, ipfsAPi.client.Client should use the default value rather than trying to work with None. This makes the module easier to use; consider, for example, if I have a Python client that includes:

import argparse

def parse_args():
    p = argparse.ArgumentParser()
    p.add_argument('--host')
    p.add_argument('--port')
    p.add_argument('--base')
    return p.parse_args()

I would like to be able to do this...

api = ipfsApi.Client(host=args.host, port=args.port, base=args.base)

...rather than requiring a complex set of conditionals to deal with various combinations of user-specified vs. user-wants-the-default values.

larsks added a commit to larsks/python-ipfs-api that referenced this issue Sep 10, 2015
This permits the caller to request the default value explicitly
by pasing None to either host, port, or base when instantiating
ipfsApi.client.Client.

Closes ipfs-shipyard#7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant