<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[Python Forum - All Forums]]></title>
		<link>https://python-forum.io/</link>
		<description><![CDATA[Python Forum - https://python-forum.io]]></description>
		<pubDate>Wed, 23 Sep 2026 18:08:29 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[inventory management system]]></title>
			<link>https://python-forum.io/thread-46427.html</link>
			<pubDate>Mon, 21 Sep 2026 03:07:26 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=44076">StellaSalazar</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46427.html</guid>
			<description><![CDATA[Hi everyone,<br />
<br />
For my Python homework, I need to create a small inventory management program for a shop.<br />
<br />
The program should allow the user to:<br />
<br />
View the current stock.<br />
Add new products.<br />
Update the quantity of an existing product.<br />
Display products that have fewer than 5 items remaining.<br />
<br />
I started with a dictionary:<br />
<br />
<pre class="brush: python" title="Python Code:">inventory = {
"notebook": 12,
"pen": 25,
"backpack": 4,
"water bottle": 8
}

product = input("Enter product name: ")
quantity = int(input("Enter quantity to add: "))

inventory[product] += quantity

print(inventory)</pre>]]></description>
			<content:encoded><![CDATA[Hi everyone,<br />
<br />
For my Python homework, I need to create a small inventory management program for a shop.<br />
<br />
The program should allow the user to:<br />
<br />
View the current stock.<br />
Add new products.<br />
Update the quantity of an existing product.<br />
Display products that have fewer than 5 items remaining.<br />
<br />
I started with a dictionary:<br />
<br />
<pre class="brush: python" title="Python Code:">inventory = {
"notebook": 12,
"pen": 25,
"backpack": 4,
"water bottle": 8
}

product = input("Enter product name: ")
quantity = int(input("Enter quantity to add: "))

inventory[product] += quantity

print(inventory)</pre>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Homework question: Python file handling and average calculation]]></title>
			<link>https://python-forum.io/thread-46426.html</link>
			<pubDate>Mon, 21 Sep 2026 03:04:02 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=44076">StellaSalazar</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46426.html</guid>
			<description><![CDATA[I’m working on a Python homework assignment about reading data from a text file and calculating the average score of the students.<br />
<br />
The assignment asks me to:<br />
<br />
Read student names and scores from a text file.<br />
Calculate the average score for each student.<br />
Display the student with the highest average score.<br />
<br />
I tried to write the program myself, but I’m having trouble when I calculate the average. My program works for some inputs, but sometimes I get an error or an incorrect result.<br />
<br />
Here is a simplified version of my code:<br />
<br />
<pre class="brush: python" title="Python Code:">students = {
"Anna": [8, 7, 9],
"Ben": [6, 8, 7],
"Chris": [9, 10, 8]
}

averages = {}

for name, scores in students.items():
total = sum(scores)
average = total / len(scores)
averages[name] = average

highest = max(averages)

print("Average scores:", averages)
print("Student with the highest average:", highest)</pre>The output I expected was that Chris would have the highest average. However, the program prints the wrong student.<br />
<br />
I think the problem may be related to the way I use max(), but I’m not sure how to fix it.<br />
<br />
What I have tried:<br />
<br />
I checked the values stored in the averages dictionary.<br />
I used sum() and len() to calculate the averages.<br />
I searched for examples of using max() with dictionaries, but I’m still confused about how it works.<br />
<br />
Could someone explain what is wrong with my use of max() and give me a hint about how I should approach it? I’d like to understand the solution rather than just copy the code.<br />
<br />
System information:<br />
<br />
Python: 3.12<br />
OS: Windows 11<br />
IDE: Visual Studio Code]]></description>
			<content:encoded><![CDATA[I’m working on a Python homework assignment about reading data from a text file and calculating the average score of the students.<br />
<br />
The assignment asks me to:<br />
<br />
Read student names and scores from a text file.<br />
Calculate the average score for each student.<br />
Display the student with the highest average score.<br />
<br />
I tried to write the program myself, but I’m having trouble when I calculate the average. My program works for some inputs, but sometimes I get an error or an incorrect result.<br />
<br />
Here is a simplified version of my code:<br />
<br />
<pre class="brush: python" title="Python Code:">students = {
"Anna": [8, 7, 9],
"Ben": [6, 8, 7],
"Chris": [9, 10, 8]
}

averages = {}

for name, scores in students.items():
total = sum(scores)
average = total / len(scores)
averages[name] = average

highest = max(averages)

print("Average scores:", averages)
print("Student with the highest average:", highest)</pre>The output I expected was that Chris would have the highest average. However, the program prints the wrong student.<br />
<br />
I think the problem may be related to the way I use max(), but I’m not sure how to fix it.<br />
<br />
What I have tried:<br />
<br />
I checked the values stored in the averages dictionary.<br />
I used sum() and len() to calculate the averages.<br />
I searched for examples of using max() with dictionaries, but I’m still confused about how it works.<br />
<br />
Could someone explain what is wrong with my use of max() and give me a hint about how I should approach it? I’d like to understand the solution rather than just copy the code.<br />
<br />
System information:<br />
<br />
Python: 3.12<br />
OS: Windows 11<br />
IDE: Visual Studio Code]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[I made an app to automatically update Python]]></title>
			<link>https://python-forum.io/thread-46424.html</link>
			<pubDate>Sat, 19 Sep 2026 04:09:52 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=44074">JacRob32</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46424.html</guid>
			<description><![CDATA[Hi everyone,<br />
  I noticed there was not really any good way to automatically update the Python installation on a computer. So I made an app that automatically fetches the newset release from python.org, and asks you if you want to install it. The app then automatically pulls the update and installs it. <br />
  The app and the source code can be found at <span style="color: #3498DB;" class="mycode_color"><a href="https://github.com/JacRob32/Python-Updater" target="_blank" rel="noopener" class="mycode_url">https://github.com/JacRob32/Python-Updater</a></span>. It is currently only built for macOS, but I intend to make a Windows version soon. <br />
  If you have any suggestions or problems, let me know below. If you want to contribute or add a feature, you could mention it below and add a pull request on GitHub.<br />
<span style="font-weight: bold;" class="mycode_b">Image:<br />
</span><img src="https://res.cloudinary.com/weudzd6v/image/upload/v1789791172/Screenshot_2026-09-18_at_9.11.53_PM.png" loading="lazy"  alt="[Image: Screenshot_2026-09-18_at_9.11.53_PM.png]" class="mycode_img" />]]></description>
			<content:encoded><![CDATA[Hi everyone,<br />
  I noticed there was not really any good way to automatically update the Python installation on a computer. So I made an app that automatically fetches the newset release from python.org, and asks you if you want to install it. The app then automatically pulls the update and installs it. <br />
  The app and the source code can be found at <span style="color: #3498DB;" class="mycode_color"><a href="https://github.com/JacRob32/Python-Updater" target="_blank" rel="noopener" class="mycode_url">https://github.com/JacRob32/Python-Updater</a></span>. It is currently only built for macOS, but I intend to make a Windows version soon. <br />
  If you have any suggestions or problems, let me know below. If you want to contribute or add a feature, you could mention it below and add a pull request on GitHub.<br />
<span style="font-weight: bold;" class="mycode_b">Image:<br />
</span><img src="https://res.cloudinary.com/weudzd6v/image/upload/v1789791172/Screenshot_2026-09-18_at_9.11.53_PM.png" loading="lazy"  alt="[Image: Screenshot_2026-09-18_at_9.11.53_PM.png]" class="mycode_img" />]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[How can I improve the performance of a Python script that processes large amounts of]]></title>
			<link>https://python-forum.io/thread-46422.html</link>
			<pubDate>Fri, 18 Sep 2026 08:15:54 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=44071">molybdenumproducts1122</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46422.html</guid>
			<description><![CDATA[I’m working on a Python script that processes a relatively large dataset, and I’ve noticed that the execution time increases significantly as the amount of data grows<a href="https://molybdenumproducts.com/molybdenum/molybdenum-rod-manufacturer-india" target="_blank" rel="noopener" class="mycode_url"><span style="color: black;" class="mycode_color">.</span></a> I’m currently using standard loops and functions, but I’m wondering whether there are better approaches for improving performance.<br />
<br />
Would using list comprehensions, generators, built-in functions, or different data structures make a noticeable difference? Also, what is the best way to measure which part of the code is taking the most time?<br />
<br />
I’d appreciate any suggestions or examples of how you normally approach performance optimization in Python.]]></description>
			<content:encoded><![CDATA[I’m working on a Python script that processes a relatively large dataset, and I’ve noticed that the execution time increases significantly as the amount of data grows<a href="https://molybdenumproducts.com/molybdenum/molybdenum-rod-manufacturer-india" target="_blank" rel="noopener" class="mycode_url"><span style="color: black;" class="mycode_color">.</span></a> I’m currently using standard loops and functions, but I’m wondering whether there are better approaches for improving performance.<br />
<br />
Would using list comprehensions, generators, built-in functions, or different data structures make a noticeable difference? Also, what is the best way to measure which part of the code is taking the most time?<br />
<br />
I’d appreciate any suggestions or examples of how you normally approach performance optimization in Python.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[SOLVED] [listbox] Read-only?]]></title>
			<link>https://python-forum.io/thread-46413.html</link>
			<pubDate>Sat, 12 Sep 2026 10:37:10 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=11957">Winfried</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46413.html</guid>
			<description><![CDATA[Hello,<br />
<br />
Neither Google nor the archives here helped.<br />
<br />
Can a <a href="https://wxpython.org/Phoenix/docs/html/wx.ListBox.html" target="_blank" rel="noopener" class="mycode_url">listbox</a> be made read-only, so that the user cannot change the selections I made through code?<br />
<br />
Cheers,<br />
<br />
--<br />
Edit<br />
<br />
<pre class="brush: python" title="Python Code:">#Not good: User can't scroll :-/
self.lb1.Disable()</pre>--<br />
Edit: Work-around<br />
<br />
<pre class="brush: python" title="Python Code:">def __init__(self, *args, **kwargs):  
	...
	self.lb1 = wx.ListBox(panel, style=wx.LB_MULTIPLE)
	sizer.Add(self.lb1,1, wx.ALL | wx.EXPAND ,5)
	self.lb1.Bind(wx.EVT_LEFT_DOWN, self.on_input_intercept)
	self.lb1.Bind(wx.EVT_KEY_DOWN, self.on_input_intercept)
	...
	
def on_input_intercept(self, event):
	# Do NOT call event.Skip(). The event dies here, ignoring the user's action.
	return</pre>]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
Neither Google nor the archives here helped.<br />
<br />
Can a <a href="https://wxpython.org/Phoenix/docs/html/wx.ListBox.html" target="_blank" rel="noopener" class="mycode_url">listbox</a> be made read-only, so that the user cannot change the selections I made through code?<br />
<br />
Cheers,<br />
<br />
--<br />
Edit<br />
<br />
<pre class="brush: python" title="Python Code:">#Not good: User can't scroll :-/
self.lb1.Disable()</pre>--<br />
Edit: Work-around<br />
<br />
<pre class="brush: python" title="Python Code:">def __init__(self, *args, **kwargs):  
	...
	self.lb1 = wx.ListBox(panel, style=wx.LB_MULTIPLE)
	sizer.Add(self.lb1,1, wx.ALL | wx.EXPAND ,5)
	self.lb1.Bind(wx.EVT_LEFT_DOWN, self.on_input_intercept)
	self.lb1.Bind(wx.EVT_KEY_DOWN, self.on_input_intercept)
	...
	
def on_input_intercept(self, event):
	# Do NOT call event.Skip(). The event dies here, ignoring the user's action.
	return</pre>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[SOLVED] [sqlite] ? + LIKE?]]></title>
			<link>https://python-forum.io/thread-46421.html</link>
			<pubDate>Tue, 15 Sep 2026 20:53:54 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=11957">Winfried</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46421.html</guid>
			<description><![CDATA[Hello,<br />
<br />
Google didn't help. I tried a bunch of things, but still can't find how to use the ? syntax to prevent SQL injection while still using the LIKE operator.<br />
<br />
<pre class="brush: python" title="Python Code:">book = input("Words to search for? ")
conn = sqlite3.connect(MYDB)
cur = conn.cursor()

#BAD cur.execute("SELECT DISTINCT title FROM books WHERE title LIKE '?'", "%book%")
#BAD cur.execute("SELECT DISTINCT title FROM books WHERE title LIKE '%?%'", book)
cur.execute("SELECT DISTINCT title FROM books WHERE title LIKE '%%?%%'", book)
for row in cur.fetchall():
	print(row[0])

conn.close()</pre>Thank  you.]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
Google didn't help. I tried a bunch of things, but still can't find how to use the ? syntax to prevent SQL injection while still using the LIKE operator.<br />
<br />
<pre class="brush: python" title="Python Code:">book = input("Words to search for? ")
conn = sqlite3.connect(MYDB)
cur = conn.cursor()

#BAD cur.execute("SELECT DISTINCT title FROM books WHERE title LIKE '?'", "%book%")
#BAD cur.execute("SELECT DISTINCT title FROM books WHERE title LIKE '%?%'", book)
cur.execute("SELECT DISTINCT title FROM books WHERE title LIKE '%%?%%'", book)
for row in cur.fetchall():
	print(row[0])

conn.close()</pre>Thank  you.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[listbox] Edit items?]]></title>
			<link>https://python-forum.io/thread-46414.html</link>
			<pubDate>Sun, 13 Sep 2026 07:48:29 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=11957">Winfried</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46414.html</guid>
			<description><![CDATA[Hello,<br />
<br />
A search through Google and the archives here returned nothing.<br />
<br />
Is it possible to edit items in a listbox, either through wx.ListBox or the wx.ItemContainer? I'd like to append something to the strings as I perform a task in a loop:<br />
<br />
<pre class="brush: python" title="Python Code:">items = [self.lb1.GetString(i) for i in range(self.lb1.GetCount())]
for item in items:
	#do something
	#modify string in listbox</pre>Cheers,<br />
<br />
--<br />
Edit: Unless there's a way to get the item's position in the original list, I'll increment my own counter and use the SetString() method:<br />
<br />
<pre class="brush: python" title="Python Code:">items = [self.lb1.GetString(i) for i in range(self.lb1.GetCount())]
index = 0
for item in items:
	#do stuff
	self.lb1.SetString(index, f"{item} DONE")
	index += 1</pre>--<br />
Edit: Simpler way to get items:<br />
<br />
<pre class="brush: python" title="Python Code:">index = 0
for item in self.lb1.GetStrings():
	self.lb1.SetString(index, f"{item} DONE")
	index += 1</pre>]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
A search through Google and the archives here returned nothing.<br />
<br />
Is it possible to edit items in a listbox, either through wx.ListBox or the wx.ItemContainer? I'd like to append something to the strings as I perform a task in a loop:<br />
<br />
<pre class="brush: python" title="Python Code:">items = [self.lb1.GetString(i) for i in range(self.lb1.GetCount())]
for item in items:
	#do something
	#modify string in listbox</pre>Cheers,<br />
<br />
--<br />
Edit: Unless there's a way to get the item's position in the original list, I'll increment my own counter and use the SetString() method:<br />
<br />
<pre class="brush: python" title="Python Code:">items = [self.lb1.GetString(i) for i in range(self.lb1.GetCount())]
index = 0
for item in items:
	#do stuff
	self.lb1.SetString(index, f"{item} DONE")
	index += 1</pre>--<br />
Edit: Simpler way to get items:<br />
<br />
<pre class="brush: python" title="Python Code:">index = 0
for item in self.lb1.GetStrings():
	self.lb1.SetString(index, f"{item} DONE")
	index += 1</pre>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[fixed] Separate File Name From File Path]]></title>
			<link>https://python-forum.io/thread-46412.html</link>
			<pubDate>Fri, 11 Sep 2026 12:45:50 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=44059">kanungosteel</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46412.html</guid>
			<description><![CDATA[Hi,<br />
<br />
I'm working with Python's os.path module and I'm trying to find a simple way to extract the directory path from a complete file path. I have searched through the available functions, but I haven't found the exact one I need.<br />
<br />
For example, suppose I have the following path:<br />
<br />
/X/Y/Z/file.txt<br />
<br />
I want to get only the directory portion:<br />
<br />
/X/Y/Z<br />
<br />
Is there a built-in function in os.path that can do this easily? I'm looking for something similar to the reverse of os.path.join()<a href="https://kanungosteel.com" target="_blank" rel="noopener" class="mycode_url"><span style="color: black;" class="mycode_color">.</span></a><br />
<br />
I would appreciate any suggestions or examples.]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
I'm working with Python's os.path module and I'm trying to find a simple way to extract the directory path from a complete file path. I have searched through the available functions, but I haven't found the exact one I need.<br />
<br />
For example, suppose I have the following path:<br />
<br />
/X/Y/Z/file.txt<br />
<br />
I want to get only the directory portion:<br />
<br />
/X/Y/Z<br />
<br />
Is there a built-in function in os.path that can do this easily? I'm looking for something similar to the reverse of os.path.join()<a href="https://kanungosteel.com" target="_blank" rel="noopener" class="mycode_url"><span style="color: black;" class="mycode_color">.</span></a><br />
<br />
I would appreciate any suggestions or examples.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[pygame not importing]]></title>
			<link>https://python-forum.io/thread-46404.html</link>
			<pubDate>Wed, 09 Sep 2026 13:45:15 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=44051">brickman21</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46404.html</guid>
			<description><![CDATA[I'm using python in visual studios.<br />
I ran:<br />
import pygame<br />
print("pygame here")<br />
<br />
I get:<br />
PS C:\Users|kds_m\AppData\Local\programs\Microsoft VS Code&gt; &amp; C:\Users\kds_m\Local\Python\pythoncore-3.14-64\python.exe "c:/Users/kds_m/AppData/Local/Programs/Microsoft VS Code/main.py"<br />
Traceback (most recent call last):<br />
File  "c:/Users/kds_m/AppData/Local/Programs/Microsoft VS Code/main.py", line 1, in &lt;module&gt;<br />
import pygame<br />
ModuleNotFoundError: No module named 'pygame'<br />
PS C:\Users|kds_m\AppData\Local\programs\Microsoft VS Code&gt;<br />
<br />
I did install pygame<br />
using pip install pygame]]></description>
			<content:encoded><![CDATA[I'm using python in visual studios.<br />
I ran:<br />
import pygame<br />
print("pygame here")<br />
<br />
I get:<br />
PS C:\Users|kds_m\AppData\Local\programs\Microsoft VS Code&gt; &amp; C:\Users\kds_m\Local\Python\pythoncore-3.14-64\python.exe "c:/Users/kds_m/AppData/Local/Programs/Microsoft VS Code/main.py"<br />
Traceback (most recent call last):<br />
File  "c:/Users/kds_m/AppData/Local/Programs/Microsoft VS Code/main.py", line 1, in &lt;module&gt;<br />
import pygame<br />
ModuleNotFoundError: No module named 'pygame'<br />
PS C:\Users|kds_m\AppData\Local\programs\Microsoft VS Code&gt;<br />
<br />
I did install pygame<br />
using pip install pygame]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[I'm working on a program that will log data from a CAN bus]]></title>
			<link>https://python-forum.io/thread-46401.html</link>
			<pubDate>Fri, 04 Sep 2026 07:56:15 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=44046">Selike</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46401.html</guid>
			<description><![CDATA[I'm working on a program that will log data from a CAN bus (over serial) and help me reverse engineer the messages.<br />
<div style="text-align: right;" class="mycode_align"><a href="https://gettingoverit.io" target="_blank" rel="noopener" class="mycode_url"><span style="font-size: xx-small;" class="mycode_size">getting over it</span></a></div>
I'll be logging the incoming messages in a database (easy enough).<br />
<br />
Before I reinvent the wheel and write code to keep a filtered view of the records in the database up to date, is there a prebuilt control that already does this?<br />
<br />
I'm picturing something like a Tkinter Treeview populated by a SQL command that automatically displays any new record that is logged into the database which matches the SQL command.<br />
<br />
I only mention Tkinter as that's what I'm familiar with ... please let me know if this would be easier in some other GUI toolkit.]]></description>
			<content:encoded><![CDATA[I'm working on a program that will log data from a CAN bus (over serial) and help me reverse engineer the messages.<br />
<div style="text-align: right;" class="mycode_align"><a href="https://gettingoverit.io" target="_blank" rel="noopener" class="mycode_url"><span style="font-size: xx-small;" class="mycode_size">getting over it</span></a></div>
I'll be logging the incoming messages in a database (easy enough).<br />
<br />
Before I reinvent the wheel and write code to keep a filtered view of the records in the database up to date, is there a prebuilt control that already does this?<br />
<br />
I'm picturing something like a Tkinter Treeview populated by a SQL command that automatically displays any new record that is logged into the database which matches the SQL command.<br />
<br />
I only mention Tkinter as that's what I'm familiar with ... please let me know if this would be easier in some other GUI toolkit.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Marc Parizeau]]></title>
			<link>https://python-forum.io/thread-46399.html</link>
			<pubDate>Mon, 31 Aug 2026 21:20:42 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=44037">VincentB</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46399.html</guid>
			<description><![CDATA[Bonjour mes pythoners préférés<br />
<br />
Je me demandais si quelqu'un pouvais me confirmer l'existence de Marc Parizeau, mettez en commentaire SVP.<br />
<br />
Bonne Journée,<br />
<br />
Vincent B]]></description>
			<content:encoded><![CDATA[Bonjour mes pythoners préférés<br />
<br />
Je me demandais si quelqu'un pouvais me confirmer l'existence de Marc Parizeau, mettez en commentaire SVP.<br />
<br />
Bonne Journée,<br />
<br />
Vincent B]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[BeautifulSoup] Prepend CRLF before insert()?]]></title>
			<link>https://python-forum.io/thread-46398.html</link>
			<pubDate>Fri, 28 Aug 2026 04:29:02 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=11957">Winfried</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46398.html</guid>
			<description><![CDATA[Hello,<br />
<br />
I need to insert an element, but can't find how to have a CRLF inserted before the element.<br />
<br />
Does someone know?<br />
<br />
Thank you.<br />
<br />
<pre class="brush: python" title="Python Code:">from bs4 import BeautifulSoup, Comment

soup = BeautifulSoup(open("input.gpx", encoding='utf-8'), features='xml')
name = soup.new_tag("name")
name.string = "blah"
doc = soup.select_one("gpx")
#How to tell BS to insert a CRLF before the new element?
#&lt;gpx&gt;&lt;name&gt;blah&lt;/name&gt;
doc.insert(0,name)</pre>---<br />
Edit: Work-around<br />
<br />
<pre class="brush: python" title="Python Code:">from bs4 import BeautifulSoup
from bs4.builder import LXMLTreeBuilderForXML

#To prevent CRLF for &lt;name&gt;
#https://michaelcurrin.github.io/dev-cheatsheets/cheatsheets/python/libraries/beautifulsoup.html
builder = LXMLTreeBuilderForXML(preserve_whitespace_tags=["name"])

soup = BeautifulSoup(open("blah.gpx", encoding='utf-8'), builder=builder,features='xml')

print(soup.prettify())</pre>]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I need to insert an element, but can't find how to have a CRLF inserted before the element.<br />
<br />
Does someone know?<br />
<br />
Thank you.<br />
<br />
<pre class="brush: python" title="Python Code:">from bs4 import BeautifulSoup, Comment

soup = BeautifulSoup(open("input.gpx", encoding='utf-8'), features='xml')
name = soup.new_tag("name")
name.string = "blah"
doc = soup.select_one("gpx")
#How to tell BS to insert a CRLF before the new element?
#&lt;gpx&gt;&lt;name&gt;blah&lt;/name&gt;
doc.insert(0,name)</pre>---<br />
Edit: Work-around<br />
<br />
<pre class="brush: python" title="Python Code:">from bs4 import BeautifulSoup
from bs4.builder import LXMLTreeBuilderForXML

#To prevent CRLF for &lt;name&gt;
#https://michaelcurrin.github.io/dev-cheatsheets/cheatsheets/python/libraries/beautifulsoup.html
builder = LXMLTreeBuilderForXML(preserve_whitespace_tags=["name"])

soup = BeautifulSoup(open("blah.gpx", encoding='utf-8'), builder=builder,features='xml')

print(soup.prettify())</pre>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[opencv not setting pixels]]></title>
			<link>https://python-forum.io/thread-46396.html</link>
			<pubDate>Mon, 24 Aug 2026 21:54:25 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=44028">I_huff_paint</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46396.html</guid>
			<description><![CDATA[im working on some image processing with opencv, but when i set pixels nothing actually happens. the program outputs what it should but just doesnt set the pixels, does someone know why?<br />
<br />
heres the code:<br />
<br />
<pre class="brush: python" title="Python Code:">import cv2

img = cv2.imread('peppers2.png', 0)
x = 0
y = 0
img[x,y] = 0
#print(img.shape[0])
for y in range(0, img.shape[0], 1): 
    for x in range(0, img.shape[0], 1): 
        if img[x,y] &gt;= 127:
            print("white")
            img[x,y] = 255
        else:
            print("black")
            img[x,y] = 0
        print(x,",", y)
        x + 1
        if x in [img.shape[0]-1]:
#            print("TRUE")
            x = 0
            y + 1</pre>]]></description>
			<content:encoded><![CDATA[im working on some image processing with opencv, but when i set pixels nothing actually happens. the program outputs what it should but just doesnt set the pixels, does someone know why?<br />
<br />
heres the code:<br />
<br />
<pre class="brush: python" title="Python Code:">import cv2

img = cv2.imread('peppers2.png', 0)
x = 0
y = 0
img[x,y] = 0
#print(img.shape[0])
for y in range(0, img.shape[0], 1): 
    for x in range(0, img.shape[0], 1): 
        if img[x,y] &gt;= 127:
            print("white")
            img[x,y] = 255
        else:
            print("black")
            img[x,y] = 0
        print(x,",", y)
        x + 1
        if x in [img.shape[0]-1]:
#            print("TRUE")
            x = 0
            y + 1</pre>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[[SOLVED] [csv] Update?]]></title>
			<link>https://python-forum.io/thread-46395.html</link>
			<pubDate>Thu, 20 Aug 2026 17:36:50 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=11957">Winfried</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46395.html</guid>
			<description><![CDATA[Hello,<br />
<br />
Although the csv module provides an append() method, I don't see the changes after relooping through the rows:<br />
<br />
Is it to be expected? Is there a work-around?<br />
<br />
Thank you.<br />
<br />
<pre class="brush: python" title="Python Code:">import csv

data = csv.reader(file := open("input.txt", "r"))
for row_out in data:
	row_out.append("blah")

#not updated!
file.seek(0)
for row in data:
	print(row)</pre>]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
Although the csv module provides an append() method, I don't see the changes after relooping through the rows:<br />
<br />
Is it to be expected? Is there a work-around?<br />
<br />
Thank you.<br />
<br />
<pre class="brush: python" title="Python Code:">import csv

data = csv.reader(file := open("input.txt", "r"))
for row_out in data:
	row_out.append("blah")

#not updated!
file.seek(0)
for row in data:
	print(row)</pre>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Better way to get the last row of a csv?]]></title>
			<link>https://python-forum.io/thread-46393.html</link>
			<pubDate>Thu, 20 Aug 2026 13:26:36 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://python-forum.io/member.php?action=profile&uid=3079">Pedroski55</a>]]></dc:creator>
			<guid isPermaLink="false">https://python-forum.io/thread-46393.html</guid>
			<description><![CDATA[I need to get the last row of my csv, the crop coordinates of an image.<br />
<br />
At the moment, I get the coordinates as below. Basically, loop through all rows until we get to the last row.<br />
<br />
Is there a quicker way to do this, i.e. get the last row of the csv? <br />
<br />
My csv will never be more than 102 rows, but imagine I had 4 million rows or more! (Put the coords in some other place?? Just thought of that!)<br />
<br />
<pre class="brush: python" title="Python Code:"># get the crop coordinates for cropping the 1-page PDFs
    def get_coords(self):
        print('********************')
        print('This get_coords(self) ')
        with open(self.AKfile) as infile:
            reader = csv.reader(infile)
            last_row = None
            for row in reader: # basically loop through all rows till none are left. Can we do this better?
                last_row = row 
            if last_row:
                print(f'The last row of the csv looks like: {last_row}')
                # need integers, not string, convert
                for i in range(len(last_row)):
                    last_row[i] = int(last_row[i])
            coords = []
            for n in range(0, len(last_row), 4):
                tup = tuple(last_row[n:n+4])
                coords.append(tup)
            print(f'The crop coordinates now are: {coords}')
            print('********************\n')
            return coords</pre>]]></description>
			<content:encoded><![CDATA[I need to get the last row of my csv, the crop coordinates of an image.<br />
<br />
At the moment, I get the coordinates as below. Basically, loop through all rows until we get to the last row.<br />
<br />
Is there a quicker way to do this, i.e. get the last row of the csv? <br />
<br />
My csv will never be more than 102 rows, but imagine I had 4 million rows or more! (Put the coords in some other place?? Just thought of that!)<br />
<br />
<pre class="brush: python" title="Python Code:"># get the crop coordinates for cropping the 1-page PDFs
    def get_coords(self):
        print('********************')
        print('This get_coords(self) ')
        with open(self.AKfile) as infile:
            reader = csv.reader(infile)
            last_row = None
            for row in reader: # basically loop through all rows till none are left. Can we do this better?
                last_row = row 
            if last_row:
                print(f'The last row of the csv looks like: {last_row}')
                # need integers, not string, convert
                for i in range(len(last_row)):
                    last_row[i] = int(last_row[i])
            coords = []
            for n in range(0, len(last_row), 4):
                tup = tuple(last_row[n:n+4])
                coords.append(tup)
            print(f'The crop coordinates now are: {coords}')
            print('********************\n')
            return coords</pre>]]></content:encoded>
		</item>
	</channel>
</rss>