Question

test.py:

def fun():
    print 'Function'

if __name__ == '__main__':
    fun()

$ python -m pdb test.py:

> /home/h/CARDIO/WorkSpace/PDB/test.py(4)<module>()
-> def fun():
(Pdb) n
> /home/h/CARDIO/WorkSpace/PDB/test.py(7)<module>()
-> if __name__ == '__main__':
(Pdb) n
> /home/h/CARDIO/WorkSpace/PDB/test.py(8)<module>()
-> fun()
(Pdb) n
Function
--Return--
> /home/h/CARDIO/WorkSpace/PDB/test.py(8)<module>()->None
-> fun()
(Pdb) n
--Return--
> <string>(1)<module>()->None
(Pdb) n
The program finished and will be restarted
  1. What does the <module> and ->None refer to ?
  2. It seems fun() took two n to finish. fun() is a single statement, shouldn't n step one statement at a time ? Why does fun() take two n?
  3. I really don't know the meaning of --Return-- > <string>(1)<module>()->None. Not a single word or sign.
Était-ce utile?

La solution

  1. None is the return value of your function. Module is is the function which returned which in your case is the actual module.
  2. The first occurrence of ->def fun(): is where the function gets defined. The second one it got called.
  3. I don't now why the signature of your module looks like this. It might be because you are debuging it and it's run inside pdb.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top