Simple question: how do I print output from .get() method

Chris Angelico rosuav at gmail.com
Wed May 30 01:51:58 EDT 2018


On Wed, May 30, 2018 at 3:44 PM, MrMagoo2018 <Ronaldon2018 at gmail.com> wrote:
> Hello folks, imagine I have the code below and I am getting the "error" message when attempting to print() the output of 'sw_report'.
> Can you suggest which method I should use to retrieve this? Is that a dictionary maybe?
>
> from arista import arista
> m = arista()
> m.authenticate ("user","password")
> sw_report = m.np.sw_report.get("swType="EOS",swMajorVersion="5.0")
> print (sw_report)
> <generator object arista._result_iterate at 0x7fdb30f0af10>

That's not an error message. You asked Python to print it out, and it
printed it out. As it happens, the display isn't particularly useful,
but it's not an error.

What you have is a *generator object*, which is something you can
iterate over. I don't know about the arista library, so I don't know
what you'll get from that, but at its simplest, you could convert that
to a list:

print(list(sw_report))

ChrisA



More information about the Python-list mailing list