Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96363

Re: RPI.GPIO Help

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'elif': 0.04; 'bug.': 0.07; 'blue': 0.09; 'elegant,': 0.09; 'bug': 0.10; 'subject:Help': 0.10; 'variables': 0.15; '(2,': 0.16; '3",': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'newsgroups': 0.16; 'pressed': 0.16; 'pythonic': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'scopes': 0.16; 'value;': 0.16; 'wrote:': 0.16; 'work,': 0.21; 'strip': 0.22; 'pass': 0.22; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'followed': 0.27; 'testing.': 0.29; 'code:': 0.29; 'fixed': 0.31; 'received:84': 0.32; 'problem': 0.33; 'shorter': 0.33; 'true.': 0.33; 'similar': 0.33; 'false': 0.35; 'something': 0.35; 'but': 0.36; 'too': 0.36; 'there': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'expect': 0.37; 'thanks': 0.37; 'seem': 0.37; 'starting': 0.37; 'doing': 0.38; 'button': 0.38; 'mean': 0.38; 'means': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'share': 0.61; 'john': 0.61; 'more': 0.63; 'here': 0.66; 'subject.': 0.72; 'led': 0.72; 'basics.': 0.84; 'flashing': 0.84; 'leds': 0.84; 'non-zero': 0.84; 'yellow': 0.84; 'colour': 0.91; 'mistakes': 0.95
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=MbeRwMLf c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=IkcTkHD0fZMA:10 a=9rmJLL5phbp3o9HaJ04A:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett@:2500
Subject Re: RPI.GPIO Help
To python-list@python.org
References <lG5Ax.73238$E26.47630@fx20.iad> <MKhIx.9889$6l6.5720@fx08.iad> <V%EIx.91820$zz6.84582@fx04.iad>
From MRAB <python@mrabarnett.plus.com>
Date Fri, 11 Sep 2015 19:49:15 +0100
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0
MIME-Version 1.0
In-Reply-To <V%EIx.91820$zz6.84582@fx04.iad>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.379.1441997544.8327.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1441997544 news.xs4all.nl 23865 [2001:888:2000:d::a6]:55498
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:96363

Show key headers only | View raw


On 2015-09-11 19:24, John McKenzie wrote:
>
>   Hello.
>
>   Thanks to the help of people here and in other newsgroups I seem to have
> something working doing the basics. (Buttons work, colours light up
> appropriately.)
>
>   When I followed MRAB's instructions and read about scopes of variables
> that solved my most recent problem, but it introduced a bug. I think I
> fixed the bug but after all my stupid mistakes and forgetfulness that
> seems too good to be true. I expect there is a better, more elegant, or
> more Pythonic way to do what I did so please feel free to share on the
> subject.
>
>   I had a problem where if I pressed a button while the LEDs were already
> flashing the colour of that button it would block a new colour from
> starting when I pressed a new button. So if the LED strip was red and I
> pressed the red button again nothing would happen when I pressed the blue
> or yellow button. Similar problem for the other two buttons.
>
>   So inside my callbacks I added this code:
>
>     if colour == 1:
>          pass
>      elif colour == 2 or 3:
>          colour = 1
>
>
>   Now it seems OK from my limited testing.
>
[snip]

"colour == 2 or 3" means the same as "(colour == 2) or 3", where 3 is a
true value (zero is a false value; any non-zero number is a true value).

What you mean is "colour == 2 or colour == 3".

A shorter alternative is "colour in (2, 3)".

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-08-16 19:40 +0000
  Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-08-16 21:15 +0100
    Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-08-20 15:12 +0000
      Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-08-20 16:45 +0100
        Re: RPI.GPIO Help alister <alister.nospam.ware@ntlworld.com> - 2015-08-20 15:54 +0000
      Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-08-20 21:27 -0400
        Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-08-28 17:40 +0000
          Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-08-28 13:56 -0700
          Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-08-29 14:21 -0400
  Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-08-31 17:41 +0000
    Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-08-31 11:25 -0700
    Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-08-31 19:34 +0100
    Re: RPI.GPIO Help Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-09-01 10:58 +0200
  Re: RPI.GPIO Help Tim Daneliuk <tundra@bogus-city.tundraware.com> - 2015-08-31 14:07 -0500
    Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-01 02:08 -0400
  Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-02 18:50 +0000
  Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-09 19:03 +0000
    Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-09-09 20:29 +0100
  Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-10 15:56 +0000
    Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-11 18:24 +0000
      Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-09-11 19:49 +0100
      Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-09-11 12:00 -0700
      Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-09-11 12:24 -0700
      Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-11 21:10 -0400
  Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-13 06:08 +0000
    Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-13 12:24 -0400
    Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-09-14 05:53 -0700

csiph-web