Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1269

Python • Showing list contents in thonny

$
0
0
I'm working on a web scraper and I have decided to copy the target data from each site into a list of data objects so I can export to a .CSV file in an orderly manner. I have drafted that module to write each product to a data object and write the objects to a list. It works as advertised.

If i select the list object in variables and select object inspector the only information i receive is the number of items in the list and their memory address. It wound be helpful if I could look at the contents of each field in each record in the debugger without using the print statements. Is that possible in Thonny? See code below

Code:

#this routine creates a data object product, initialises the contents#with values given and stores them in a list productlist#the intention is to eventually use this code to receive data scraped from #a web page and write it our to a .CSV fileclass product:    def __init__(self, site, date, description, price):        self.site = site        self.date = date        self.description = description                self.price = price        return               productlist=list()productlist.append(product("www.somesite.com", "25MAR2025", "DescriptionTextString",  "PriceTextString"))productlist.append(product("www.someothersite.com" , "25MAR2025" , "AnotherDescriptionString", "AnotherPriceString"))def printobject(index):    print (productlist[index].site)    print (productlist[index].date)    print (productlist[index].description)    print (productlist[index].price)    print()    returnprintobject(0)printobject(1)x=1

Statistics: Posted by ras_oscar — Sun Mar 23, 2025 4:01 pm



Viewing all articles
Browse latest Browse all 1269

Trending Articles