Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys

I have a loop in Python that is responsible for the main functionality of my system. I have various string variables in the loop that are re-used on each iteration of the loop and are continuously assigned new string values.

I do not clear string variables before I assign them with new string values.

Should I be clearing each string variable before assigning a new string value??

Or are previous variable values completely overwritten when you assign a new value??

Thanks for all the help

Regards
Posted

Hi sach262,

if you're using assignment statements in the likes of
var1 = expression_yielding_a_string you'll be doing fine, whereas assignments like var1 += expression_yielding_a_String

will accumulate string content into var1.

Hope this helps.

Cheers

Manfred
 
Share this answer
 
Comments
sach262 15-Nov-10 4:08am    
thanks Manfred. appreciated
sach262 wrote:
I do not clear string variables before I assign them with new string values.

Should I be clearing each string variable before assigning a new string value??

No.


sach262 wrote:
Or are previous variable values completely overwritten when you assign a new value??

Yes.
:)
 
Share this answer
 
Comments
sach262 15-Nov-10 4:08am    
Thank you for clearing that up for me:)
CPallini 15-Nov-10 4:30am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900