[Tutor] What do each of these functions do?

Alan Gauld alan.gauld at btinternet.com
Tue Feb 16 03:52:55 EST 2016


On 16/02/16 00:00, Tom Brodle wrote:
> I have requested help related to a program before, but did not see an answer. 

If it was the post on Feb 4th then you got 2 answers
(from Joel and myself.)

> My previous programming has been with "Basic", so please give me a break.
> What do the following two lines of code do, individually,  
> 
> GPIO.cleanup()

This is, I assume from a RaspberryPi program?
If so, its not really in the scope of this group, which is for
the core Python language and library. However, as the
name suggests, it cleans up the GPIO (General Purpose Input
Output) bus connection. That usually entails freeing memory
resources and the like, none of which you really need to
worry about provided you call the function.

> quit(code=None)

This basically quits the Python interpreter.

> and where in the code does the pointer or (program counter)
> end up after it has finished that line, assuming it is the
> last line of code in each of two programs?

That doesn't really make any sense in a Python context.
Python translates your code into a Pseudocode format
that is run inside the interpreter. The interpreter is
running on the native hardware and will be incrementing
the native program counter as it goes but that has very
little correspondence to your Python code.

All you really need to know is that the Python statements
execute in sequence as self contained units.

> What document would answer my question?

If you want to know about how the Python interpreter
works then I'm not sure. If you just want to know
more about the quit() and GPIO functions then
there are documents available. For quit it's in
the standard library docs. For GPIO it will be
somewhere on your Pi installation.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list