3

I am a bit lost here:

I can not use itertools.product in my code. This is in a break point in unittest setUp method:

ipdb> import itertools
ipdb> itertools
<module 'itertools' (built-in)>
ipdb> itertools.product
<class 'itertools.product'>
ipdb> list(itertools.product([2,7], [1,4]))
*** Error in argument: '(itertools.product([2,7], [1,4]))'

I am Pretty sure that I'm not doing anything weird with the module itself since this is in my codebase (no uncommite changes there):

$ git grep itertools
simple_wbd/climate.py:import itertools

If I try this in Ipython interpreter it works fine.

In [1]: import itertools

In [2]: list(itertools.product([2,7], [1,4]))
Out[2]: [(2, 1), (2, 4), (7, 1), (7, 4)]

I don't even know how to debug this. Any help would be nice.

Thank you.

zidarsk8
  • 3,088
  • 4
  • 23
  • 30

1 Answers1

14

In this debugger, list is a command. For access to the builtin name you were intending, prepend an exclam:

ipdb> list(itertools.product([2,7], [1,4])
*** Error in argument: '(itertools.product([2,7], [1,4])'
ipdb> !list(itertools.product([2,7], [1,4]))
[(2, 1), (2, 4), (7, 1), (7, 4)]

This should not be an issue in the code itself, only within the debugger.

wim
  • 338,267
  • 99
  • 616
  • 750