What does => mean in python output and how can I get the right side value

205 Views Asked by At

I am using python-gitlab (https://github.com/python-gitlab/python-gitlab)

And in my code I want to get values from project issues:

statistics = project.issuesstatistics.get()
print(statistics)
print(type(statistics))

The output is the following:

<class 'gitlab.v4.objects.ProjectIssuesStatistics'> => {'statistics': {'counts': {'all': 1, 'closed': 0, 'opened': 1}}}
<class 'gitlab.v4.objects.ProjectIssuesStatistics'>

The right side is just a dict and I want to have the value for 'all'. But how can I get the dict from the right side? I need something like statistics.values()

2

There are 2 best solutions below

0
On

The arrow as such does not have any special meaning in this context; the designer of this particular class decided to use this formatting when you print the bare object.

(In some more detail, when you convert an object into a string, its __str__ method is called, and should return a string. It could return whatever it wants, like "42" or "=> => =>", though the usual expectation would be for it to return a string which reveals the actual value held by the object in some sort of vaguely human-readable representation.)

In the general case, you would consult the documentation for the library, or inspect what methods are available (the dir() function is helpful for this, and of course the help() function, which displays any documentation string).

0
On

In python-gitlab V4 you can use attributes property to get the value of the right hand side of the arrow. Something like this:

gl.issues.list[0].attirbutes