1

In my Python code, I have this call inside a bounded method:

instances = instance_objects.InstanceList().get_by_host(ctxt, self.host)

When I debug with the Python debugger (pdb) and I issue p instances i get this output:

InstanceList(objects=[Instance(bdfbf658-da32-445d-9560-56d496abcb9d)])

When I issue p instances.objects i get this output:

[Instance(
access_ip_v4=None,
access_ip_v6=None,
architecture=None,
auto_disk_config=False,
availability_zone=None,
cell_name=None,
cleaned=False,
vcpus=1,
)]

How can I print out the value of vcpus in pdb?

7
  • Isn't the value 1? It looks like you're getting that data when you issue p instances.objects Commented Sep 22, 2016 at 0:10
  • Yes, you are right. But I would like to have only the value 1 printed out. The thing is that this Instance is much longer than what I actually listed. What you see is only a small part of it. Commented Sep 22, 2016 at 0:43
  • Btw: is it a dict in a list? Or a tuple in a list? Commented Sep 22, 2016 at 0:45
  • Did you try p instances.objects[0].vcpus? Commented Sep 22, 2016 at 1:28
  • @DavidCullen, I'll give it a go and let you know, thx! Commented Sep 22, 2016 at 8:01

1 Answer 1

1

Try

p instances.objects[0].vcpus
Sign up to request clarification or add additional context in comments.

2 Comments

Just a short question: is it a tuple in a list? I mean, it cannot be a dict in a list because a dict has curly brackets. Right?
It looks like an instance of a class named Instance. It looks like vcpus is an attribute of the class. What is the output of p type(instances.objects[0])?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.