LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-11-2012, 09:52 PM   #1
red_fire
Member
 
Registered: Jan 2007
Location: Indonesia
Distribution: Slackware Linux
Posts: 67

Rep: Reputation: 11
noob question about unused variable in python


Hi,

I've only started programming recently
and got very interested in the idea
of writing elegant and efficient codes

my question is..
what happens to unused variables in a function
that exits due to an error (value error, index error, etc)?
 
Old 05-11-2012, 10:17 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
If by used you mean there was memory allocated, they get cleaned up just like any other variable
 
Old 05-11-2012, 11:02 PM   #3
red_fire
Member
 
Registered: Jan 2007
Location: Indonesia
Distribution: Slackware Linux
Posts: 67

Original Poster
Rep: Reputation: 11
yep,, that's what i meant

so that means whenever the function exits, all unused variables will be cleared from the memory?
 
Old 05-11-2012, 11:47 PM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
On exit any allocated memory will be released.
 
1 members found this post helpful.
Old 05-12-2012, 12:12 AM   #5
red_fire
Member
 
Registered: Jan 2007
Location: Indonesia
Distribution: Slackware Linux
Posts: 67

Original Poster
Rep: Reputation: 11
Thanks!
another learning point there
 
Old 05-12-2012, 03:11 AM   #6
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Python is pretty good with its memory management
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Python noob question grail Programming 6 01-23-2014 07:21 AM
Variable substitution (stupid noob) question in tcsh King of Men Linux - Newbie 4 12-04-2005 09:12 AM
python variable question bendeco13 Programming 6 02-03-2005 07:22 AM
python global variable? goestin Programming 1 01-20-2005 06:52 AM
Complete noob question from a noob noob_hampster Linux - Software 2 09-04-2003 12:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration