Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51839
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joshua.landau.ws@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.025 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'broken': 0.04; 'subject:Python': 0.06; 'yeah,': 0.09; 'runs': 0.10; 'cc:addr :python-list': 0.11; 'python': 0.11; 'def': 0.12; 'corresponds': 0.16; 'variants': 0.16; 'applies': 0.16; 'sender:addr:gmail.com': 0.17; 'fix': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'email addr:gmail.com>': 0.22; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'subject:Code': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; 'piece': 0.31; 'with,': 0.31; 'run': 0.32; 'subject:the': 0.34; 'problem': 0.35; 'advice': 0.35; 'problem.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'next': 0.36; 'skip:& 10': 0.38; 'even': 0.60; 'commands': 0.60; 'august': 0.61; 'telling': 0.64; 'to:addr:gmail.com': 0.65; 'car': 0.72; 'miss': 0.74; '2\xc2\xa0': 0.84; 'subject:else': 0.84; 'hardest': 0.91; 'refuse': 0.93; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=ZxA2Xbs2PTF+KwBLPbto9Y+GaoICigVLlHV++mxeSrs=; b=PpXbLy/svYbwHcnbJ1C23h3fgSW2qrNkheGvNYOawlj28oXD0NkGKuyHtSYyzADi0O dILMPBUL3HIMKSnxkzQPz2GpOaBBsEjtWsdnmjHuDAF2UGx/170PKEetiyq/g58MpEMj l2W1EAOH4QVx6H6suao9R4reavneplOOg1shd0N3mioHj6E3FC1lk9QhiD9j7KofxQDI 1r3Wa6jIgdqk3fKgFZTCHdcySu7s4DGRXAaAK99RR2NDp+DPbk9xKF7SKttetkXaEAWl 0KVVdwB6xawWGUoqme/RgKUEfHHTiJpPfJQ+W3G3I3LN7e10bVN9ZblWAciJtQgomwZf nymQ== |
| X-Received | by 10.112.200.135 with SMTP id js7mr4370191lbc.12.1375495938225; Fri, 02 Aug 2013 19:12:18 -0700 (PDT) |
| MIME-Version | 1.0 |
| Sender | joshua.landau.ws@gmail.com |
| In-Reply-To | <b16bb894-a720-4e0c-a3ce-d699afffeb8e@googlegroups.com> |
| References | <c6702eb3-494a-4359-84ef-d6679c09df35@googlegroups.com> <dfa6368b-565b-4512-8755-ef36fd2719cd@googlegroups.com> <b16bb894-a720-4e0c-a3ce-d699afffeb8e@googlegroups.com> |
| From | Joshua Landau <joshua@landau.ws> |
| Date | Sat, 3 Aug 2013 03:11:37 +0100 |
| X-Google-Sender-Auth | VSpBIDWx-WdEgUzrbB2QGniPeVE |
| Subject | Re: Python: Code is ignoring the if and else |
| To | kevin4fong@gmail.com |
| Content-Type | multipart/alternative; boundary=001a11c37e0cc9be2804e3019a34 |
| Cc | python-list <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.142.1375495945.1251.python-list@python.org> (permalink) |
| Lines | 86 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375495945 news.xs4all.nl 15873 [2001:888:2000:d::a6]:60562 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51839 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 3 August 2013 02:44, <kevin4fong@gmail.com> wrote:
> Yeah, I already know about that. But if I try to change it, I'm not even
> able to start the program. If I try to change the if statement that it
> corresponds with, I get a an error saying "card" is not a global. And if I
> try to shift it in, for some reason...the program runs through the MISS
> line multiple times.
>
You have a car with a broken engine and a broken tire and are telling us
that you refuse to fix the engine because it highlights the problem of the
broken tire.
Take the fix and move on to the next problem.
One piece of advice is about scoping. This is perhaps the hardest "gotcha"
of Python conceptually, but it's sensible once you understand the
justifications.
Run the four commands below and try and understand why this applies to your
code.
a = 1
def access_global():
print(a)
def set_variable():
a = 2
print(a)
def broken_set():
a = a + 1
print(a)
def also_broken():
print(a)
return
a = 1 # Never run!
The fix for the broken variants is to start the functions with "global a".
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python: Code is ignoring the if and else kevin4fong@gmail.com - 2013-08-02 17:40 -0700
Re: Python: Code is ignoring the if and else MRAB <python@mrabarnett.plus.com> - 2013-08-03 02:38 +0100
Re: Python: Code is ignoring the if and else John Ladasky <john_ladasky@sbcglobal.net> - 2013-08-02 18:39 -0700
Re: Python: Code is ignoring the if and else kevin4fong@gmail.com - 2013-08-02 18:44 -0700
Re: Python: Code is ignoring the if and else Chris Angelico <rosuav@gmail.com> - 2013-08-03 02:56 +0100
Re: Python: Code is ignoring the if and else Joshua Landau <joshua@landau.ws> - 2013-08-03 03:11 +0100
Re: Python: Code is ignoring the if and else kevin4fong@gmail.com - 2013-08-02 19:24 -0700
Re: Python: Code is ignoring the if and else Terry Reedy <tjreedy@udel.edu> - 2013-08-03 01:04 -0400
Re: Python: Code is ignoring the if and else kevin4fong@gmail.com - 2013-08-03 13:12 -0700
Re: Python: Code is ignoring the if and else Terry Reedy <tjreedy@udel.edu> - 2013-08-02 21:42 -0400
Re: Python: Code is ignoring the if and else kevin4fong@gmail.com - 2013-08-02 18:46 -0700
Re: Python: Code is ignoring the if and else Dave Angel <davea@davea.name> - 2013-08-03 03:34 +0000
csiph-web