Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69908
| Date | 2014-04-08 16:09 -0400 |
|---|---|
| From | Grawburg <grawburg@myglnc.com> |
| Subject | "Latching" variables in function |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9045.1397000922.18130.python-list@python.org> (permalink) |
I've probably used the wrong term - I'm thinking of what I do when writing PLC code - so I can't find how to do this in my reference books. This is part of a project I'm working on with a Raspberry Pi and an MCP23017 port expander. I have a N/O pushbutton that I want to "latch" a value to a variable when it's been pressed. I have this function that gets called periodically in a 'while True' statement: def button(): pushbutton = 0 button_value = 0 pushbutton=bus.read_byte_data(address,GPIOB) if pushbutton > 0: button_value = 1 return button_value I need button_value to become '1' when the button is pressed and to remain '1' until the entire program (only about 25 lines) ends with a sys.exit() What do I use to 'latch' button_value? Brian Grawburg North Carolina -- The truth will set you free . . .but first it will infuriate you.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
"Latching" variables in function Grawburg <grawburg@myglnc.com> - 2014-04-08 16:09 -0400
Re: "Latching" variables in function Denis McMahon <denismfmcmahon@gmail.com> - 2014-04-09 00:28 +0000
Re: "Latching" variables in function Mark H Harris <harrismh777@gmail.com> - 2014-04-09 08:53 -0500
Re: "Latching" variables in function alister <alister.nospam.ware@ntlworld.com> - 2014-04-09 15:43 +0000
csiph-web