Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function help
#4
it's not clear what b in your code is/what library is used, but if I get what you want:
def light_switch(turn_on=True):
    b.set_light([1, 2, 9, 10], 'on', turn_on)
then if you want to turn lights on
light_switch(True)
or just
light_switch()
if you want to turn off
light_switch(False)
now, as I said it's unclear what b is. so here (as well as in your code) it's a global variable, which is not ideal. there is a good chance that this could be implemented better
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Function help - by Nickd12 - Sep-15-2020, 01:01 AM
RE: Function help - by bowlofred - Sep-15-2020, 01:23 AM
RE: Function help - by Nickd12 - Sep-15-2020, 01:32 AM
RE: Function help - by buran - Sep-15-2020, 04:43 AM
RE: Function help - by bowlofred - Sep-15-2020, 04:44 AM
RE: Function help - by Nickd12 - Sep-15-2020, 06:59 AM
RE: Function help - by buran - Sep-15-2020, 07:09 AM
RE: Function help - by Nickd12 - Sep-15-2020, 07:09 AM
RE: Function help - by buran - Sep-15-2020, 07:13 AM
RE: Function help - by Nickd12 - Sep-16-2020, 07:24 PM
RE: Function help - by buran - Sep-16-2020, 07:32 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020