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


Groups > comp.lang.python > #69486

Re: Code style query: multiple assignments in if/elif tree

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.033
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; '"this': 0.03; 'subject:query': 0.07; 'curve': 0.09; 'desired,': 0.09; 'difference,': 0.09; 'linear': 0.09; 'cc:addr:python-list': 0.11; "wouldn't": 0.14; '(just': 0.16; 'bullet': 0.16; 'calculus,': 0.16; 'curve.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hits': 0.16; 'it;': 0.16; 'messy': 0.16; 'origin.': 0.16; 'unlikely': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; 'drawing': 0.19; '(the': 0.22; 'proposed': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; "aren't": 0.24; 'comparing': 0.24; 'driver': 0.24; 'subject:Code': 0.24; 'cc:2**0': 0.24; 'purposes': 0.26; 'train': 0.26; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; '[1]': 0.29; "doesn't": 0.30; '[2]': 0.30; 'absolute': 0.30; 'involving': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'url:wiki': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'url:wikipedia': 0.31; 'this.': 0.32; 'probably': 0.32; 'could': 0.34; 'beyond': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'accuracy': 0.36; 'much.': 0.36; 'url:org': 0.36; 'seconds': 0.37; 'too': 0.37; 'two': 0.37; 'being': 0.38; 'pm,': 0.38; 'that,': 0.38; 'short': 0.38; 'called': 0.40; 'how': 0.40; 'even': 0.60; 'station': 0.60; 'up,': 0.60; 'hope': 0.61; 'reaching': 0.61; 'guarantee': 0.63; 'maximum': 0.63; 'our': 0.64; 'more': 0.64; 'different': 0.65; 'chance': 0.65; 'distance': 0.65; 'land': 0.65; 'between': 0.67; 'safe': 0.72; 'soon,': 0.74; 'cater': 0.84; 'distances': 0.84; 'instantly': 0.84; 'liking': 0.84; 'story...': 0.84; 'technically': 0.84; 'treats': 0.84; 'simulation': 0.91; 'stations': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=NCJoUoXwP0inIQUUYKBTFd6URXan6gJqYWXpWMaoCt0=; b=Hi+DJ6TTuo6D5q4YBwauzvzSWDbW7TzzOzMhJMx/r4gFxgVbxwSokwFq0CKwpkJ6TV CbZq23dCFcZCKPuQIa6mjjzioLkBR4bB4rsKi3pSJWYCbUPmXftnP9oasqKBEUbWwCGr sYYseaHyGy1/FrhYEFszcuy6WO4eQxK688XZ7ozYcqg0y4ErKOLR+Qbwtm1pUQFUFjBR swdrG4dllDc9p+b9cIGeJwImrSwKi3zyXFEUYz9K2lNbsSyKY4kqpnVSv9YYcF/eFr2J HTRu7Ycl9J6/H9K67vOOJjxfClZo+AtEo8bnU7O8La7Hnoto28AJ9RtPISdC987Wb5Za VToQ==
MIME-Version 1.0
X-Received by 10.68.248.7 with SMTP id yi7mr29865695pbc.31.1396338583740; Tue, 01 Apr 2014 00:49:43 -0700 (PDT)
In-Reply-To <533a6af1$0$2909$c3e8da3$76491128@news.astraweb.com>
References <mailman.8744.1396276875.18130.python-list@python.org> <533a3fd8$0$2909$c3e8da3$76491128@news.astraweb.com> <CAPTjJmoqdHtbyTKLf0b6c5Xy8Wx_NQVvFenB-S0hE3dHO15uzA@mail.gmail.com> <CALwzidmEqc45K49c3agMzRzpAtEqejGF2svpPOZXg5X6dbBnGw@mail.gmail.com> <mailman.8774.1396335341.18130.python-list@python.org> <533a6af1$0$2909$c3e8da3$76491128@news.astraweb.com>
Date Tue, 1 Apr 2014 18:49:43 +1100
Subject Re: Code style query: multiple assignments in if/elif tree
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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 <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.8781.1396338586.18130.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1396338586 news.xs4all.nl 2900 [2001:888:2000:d::a6]:48140
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:69486

Show key headers only | View raw


On Tue, Apr 1, 2014 at 6:29 PM, Steven D'Aprano <steve@pearwood.info> wrote:
>> Okay. I never studied calculus, so this is beyond my expertise. Is this
>> going to make a majorly significant difference to the end result?
>
> I thought that there was a chance that there might be, but it turns out,
> not so much. There is a difference, but for the purposes of the
> simulation it probably doesn't matter. If you were trying to land a
> spacecraft on Mars, that's a different story...

I'm liking the idea of pretending it's linear acceleration. Our error
in the system is:

1) Distances are accurate to one meter at absolute best; and I
wouldn't guarantee that they're even that accurate.
2) The simulation will apply the brakes at some exact number of
seconds past its origin.
3) A human driver might well apply the brakes a couple of seconds too
soon, and then cruise at the curve's speed for a short distance before
actually reaching the curve.
4) A human driver might also apply the brakes too _late_, and there
are tolerances built into the curve speed limits to cater for this.
The train would rock a bit more than is desired, but it won't
instantly derail if it hits a 90km/h curve at 91km/h (which is how the
simulator treats it).

Add all that up, and the end result is unlikely to be accurate to
better than ten seconds - and that's being generous. Ultimately, this
would be for drawing up projected timetables, so it's not going to be
used at more than one-minute accuracy; although comparing two proposed
routes might technically make use of more accuracy than that ("we
could go around to the left of this, or to the right of it; which
would be the faster route?" "This one, by thirty seconds"), any
difference of less than a minute would really have to be called
"practically equal".

By the way, line speed (the maximum safe speed on straight track) is
400km/h, so your estimates involving a 320km/h bullet train are in the
right ballpark. Curves could be practically any speed between zero and
that, although one would hope there aren't any Kooyong Stations on the
route! (Just up [1] of the station [2] is a tram crossing, which for
decades has been so bumpy and messy that trains had to slow down to
about 10 or 20 kays to get through safely.)

ChrisA
[1] https://en.wikipedia.org/wiki/Rail_directions#United_Kingdom
[2] https://en.wikipedia.org/wiki/Kooyong_railway_station

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


Thread

Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 01:33 +1100
  Re: Code style query: multiple assignments in if/elif tree Marko Rauhamaa <marko@pacujo.net> - 2014-03-31 18:40 +0300
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 03:03 +1100
      Re: Code style query: multiple assignments in if/elif tree Rustom Mody <rustompmody@gmail.com> - 2014-03-31 09:20 -0700
        Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 03:29 +1100
          Re: Code style query: multiple assignments in if/elif tree "Rhodri James" <rhodri@wildebst.org.uk> - 2014-03-31 21:31 +0100
    Re: Code style query: multiple assignments in if/elif tree Ned Batchelder <ned@nedbatchelder.com> - 2014-03-31 17:42 -0400
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 09:50 +1100
    Re: Code style query: multiple assignments in if/elif tree Ben Finney <ben+python@benfinney.id.au> - 2014-04-01 09:57 +1100
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 10:12 +1100
      Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-04-01 00:57 +0000
    Re: Code style query: multiple assignments in if/elif tree Ethan Furman <ethan@stoneleaf.us> - 2014-03-31 17:30 -0700
  Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve@pearwood.info> - 2014-04-01 04:26 +0000
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 16:01 +1100
      Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve@pearwood.info> - 2014-04-01 07:20 +0000
        Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 18:35 +1100
          Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve@pearwood.info> - 2014-04-01 08:07 +0000
            Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 19:12 +1100
        Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 02:18 -0600
        Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 02:24 -0600
    Re: Code style query: multiple assignments in if/elif tree Rustom Mody <rustompmody@gmail.com> - 2014-03-31 22:45 -0700
      Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 02:05 -0400
      Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 00:28 -0600
    Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 00:13 -0600
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 02:24 -0400
    Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 00:39 -0600
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 17:55 +1100
      Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve@pearwood.info> - 2014-04-01 07:29 +0000
        Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 18:49 +1100
        Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 02:29 -0600
        Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 19:56 +1100
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 03:21 -0400
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 18:26 +1100
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 03:34 -0400
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 03:39 -0400
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 03:46 -0400
    Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 02:55 -0600

csiph-web