10000 how to check if no resource was found? · Issue #665 · sigmavirus24/github3.py · GitHub
[go: up one dir, main page]

Skip to content
how to check if no resource was found? #665
Closed
@rmamba

Description

@rmamba

How do I check if github3 does not find resource?

for example:

import github3
g = github3.GitHub(token='mytoken')
i1 = g.issue('rmamba', 'sss3', 1) #exists, returns Issue
i2 = g.issue('rmamba', 'sss3', 1000) #does not exists, return NullObject

how do I do this:

if i is None:
  handle none

I can do if i2 is i2.Empty. But then with i1 it does not work because it returns valid issue and i1.Empty does not exist. I tried with NullObject but it always says it's false.

i1 is NullObject #false
i1 is NullObject('Issue') #false

so I had to do this for now:

if '%s' % i2 == '':
  handle None

because it works for both NullObjects and valid results returned

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0