How can I get method's "args" argument value in while using ipdb?
Asked Answered
E

2

6

In ipdb using command a or args prints information on provided arguments for the method. How do I get actual args variable so I can work on the provided data?

For example when I have code:

class A(object):
    def test(*args, **kwargs):
        import ipdb; ipdb.set_trace()


A().test('testing arg')

Then after running the code I tried:

ipdb> args
args = (<__main__.A object at 0x1007bdf90>, 'testing arg')
kwargs = {}
ipdb> args[0]
args = (<__main__.A object at 0x1007bdf90>, 'testing arg')
kwargs = {}
ipdb>
Extravasation answered 8/1, 2018 at 13:18 Comment(1)
frid.github.io/blog/2014/06/05/python-ipdb-cheatsheet from there is looks like "p args" might work.Bhopal
E
11

Prefix your command with ! to disable the pdb magic.

ipdb> !args
Euton answered 8/1, 2018 at 13:20 Comment(0)
P
0

I often set dummy variables which are part of pdb magic and then use those

ipdb> aa = args
Phobos answered 12/7, 2018 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.