Issue 6903: pdb - print in for iteration prints None after printing (original) (raw)
Issue6903
Created on 2009-09-14 00:18 by MLModel, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (4) | ||
---|---|---|
msg92588 - (view) | Author: Mitchell Model (MLModel) | Date: 2009-09-14 00:18 |
Near the bottom of the library documentation for pdb there is an example of a very useful alias: alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k]) It turns out that doing print in a for loop in pdb results in None being printed on a line after each print. For example: (Pdb) for n in range(3): print(n) 0 None 1 None 2 None (Pdb) Seems like a (minor) bug, but if not, the example should be removed or replaced in the documentation. | ||
msg92675 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2009-09-16 09:56 |
This is caused by the special displayhook that pdb uses. Normally, the displayhook suppresses output when it would print None; this is not done in pdb's displayhook. This was a conscious decision, because it can remove confusion when you try to get variable values like this: (Pdb) foo (Pdb) I'll ask python-dev for what is preferred. | ||
msg92699 - (view) | Author: Mitchell Model (MLModel) | Date: 2009-09-16 16:28 |
No problem with the None's -- I see your point about that. Just that maybe the alias example should point out that the Nones will be printed so people won't be surprised and try to figure out what's wrong. --- Mitchell On Sep 16, 2009, at 5:56 AM, Georg Brandl wrote: > > Georg Brandl <georg@python.org> added the comment: > > This is caused by the special displayhook that pdb uses. > > Normally, the displayhook suppresses output when it would print None; > this is not done in pdb's displayhook. This was a conscious decision, > because it can remove confusion when you try to get variable values > like > this: > > (Pdb) foo > (Pdb) > > I'll ask python-dev for what is preferred. > > ---------- > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue6903> > _______________________________________ | ||
msg92700 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2009-09-16 16:36 |
Actually, Guido hates the Nones. :) Fixed in r74839. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:52 | admin | set | github: 51152 |
2009-09-16 16:36:52 | georg.brandl | set | status: open -> closedresolution: fixedmessages: + |
2009-09-16 16:28:53 | MLModel | set | messages: + |
2009-09-16 09:56:01 | georg.brandl | set | messages: + |
2009-09-14 00🔞24 | MLModel | create |