Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python debuggers
#1
What do you use ? There is the command line pdb at https://docs.python.org/3/library/pdb.html

Then three GUI ones mentioned at https://stackoverflow.com/posts/4929267/revisions , PyDev , Wing Python IDE and PyCharm
Reply
#2
(Jul-04-2023, 10:51 PM)jehoshua Wrote: What do you use ? There is the command line pdb at https://docs.python.org/3/library/pdb.html
I use pdb sometime,but most of time a REPL like ptpython, IPython to test stuff out Interactive.
These also do autocompletion wish is helpful.
So in my answer in your previous Thread i did use ptpython for the last testing part.
[Image: 0NBx4a.png]
Quote:Then three GUI ones mentioned at https://stackoverflow.com/posts/4929267/revisions , PyDev , Wing Python IDE and PyCharm
They have forget VS Code wich has maybe the best debugger out there.
It quite popular as you see the Python extension has 90-mil👀 downloads.
It's been my main editor for many years now.
jehoshua likes this post
Reply
#3
Thanks @snippsat . I had to lookup what REPL meant and found it to be "Read-Eval-Print Loop".

I installed ptpython and IPythonIPython . The first seemed only an editor that wasn't even checking syntax, and had no debugging features. The second an interactive shell, and I wasn't familiar with driving it, so couldn't get it to debug. Followed some examples here and there. Obviously a need to read the docs.

I also installed Wing but quickly found it wasn't simple and easy to use. This is all I'm looking for..

* An interactive python debugger that allows syntax checking and code modification, setting breakpoints, stepping through or over code, and ability to inspect variables, strings, arrays, objects,etc,etc.

..Later - have now installed Visual Studio and the Python extension, so will see if that suits my needs. Undecided
Reply
#4
Visual Studio Code and Visual Studio are different things. Your link is to Visual Studio Code, or VSCode. Both Visual Studio and VSCode can do Python, but VSCode is superior. I know a lot of people find the similar names confusing.
jehoshua likes this post
Reply
#5
(Jul-07-2023, 03:37 AM)deanhystad Wrote: Visual Studio Code and Visual Studio are different things. Your link is to Visual Studio Code, or VSCode. Both Visual Studio and VSCode can do Python, but VSCode is superior. I know a lot of people find the similar names confusing.

Thanks for picking that up. Have now had a quick check and it does seem I have installed

Quote:Version: 1.80.0
Commit: 660393deaaa6d1996740ff4880f1bad43768c814
Date: 2023-07-04T13:39:48.236Z
Electron: 22.3.14
ElectronBuildId: 21893604
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Linux x64 5.15.0-76-generic

I can't find VSCode though ? I do have the Python extension installed as well. Found this - https://www.freecodecamp.org/news/visual...sualstudio
Reply
#6
Visual Studio Code is usually referred to as VSCode.
jehoshua likes this post
Reply
#7
Visual Studio Code is certainly very powerful, thanks for recommending it. There certainly are deeper layers of variables, both locals and globals, and then variables within variables. One can easily get bogged down. Will it be easier to drive if I simply watch a few variables ? Probably. For example I get the message:

Error:
'NavigableString' object has no attribute 'children'
caused by

print(tag.children.name)
so I need to inspect "tag". Is it an object, a class, a variable ??
Reply
#8
(Jul-10-2023, 10:57 PM)jehoshua Wrote: so I need to inspect "tag". Is it an object, a class, a variable ??
Yes,this is more that you have not used Beautiful Soup much and make mistakes.
Also even if tag(bs4.element.Tag) worked,so will this not work as children is just and iterator(used in loop),and have no attributes name.

Quick example,with a xml that has more content that you previos thread.
from bs4 import BeautifulSoup

with open('breakfast.xml') as f:
    file = f.read()

soup = BeautifulSoup(file, 'xml')
food = soup.find('food')
See that food is a bs4.element.Tag.
>>> type(food)
<class 'bs4.element.Tag'
>>> food.find('price')
<price>$5.95</price>
>>> food.find('price').text
'$5.95'

# This work now but make no sense to use as this
>>> food.children
<list_iterator object at 0x0000017E966A6260>
Iterate over and get both prices.
from bs4 import BeautifulSoup

with open('breakfast.xml') as f:
    file = f.read()

soup = BeautifulSoup(file, 'xml')
for tag in soup.find_all('food'):
    print(tag.find('price'))
    print(tag.find('price').text)
Output:
<price>$5.95</price> $5.95 <price>$7.95</price> $7.95
File used breakfast.xml:
Output:
<?xml version="1.0" encoding="UTF-8"?> <breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description> Two of our famous Belgian Waffles with plenty of real maple syrup </description> <calories>650</calories> </food> <food> <name>Strawberry Belgian Waffles</name> <price>$7.95</price> <description> Light Belgian waffles covered with strawberries and whipped cream </description> <calories>900</calories> </food> </breakfast_menu>
jehoshua likes this post
Reply
#9
Thanks @snippsat Smile
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020