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


Groups > comp.lang.python > #60647

Re: python for everyday tasks

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.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.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'table.': 0.07; 'pavel': 0.09; 'python': 0.11; 'translation': 0.12; 'times,': 0.14; "wouldn't": 0.14; '"got': 0.16; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'involved?': 0.16; 'statement.': 0.16; 'subject:tasks': 0.16; 'switch.': 0.16; 'subject:python': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thu,': 0.19; 'java': 0.24; 'switch': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'ideal': 0.29; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; 'bunch': 0.31; 'table,': 0.31; 'languages': 0.32; 'implemented': 0.33; 'table': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'two': 0.37; 'implement': 0.38; 'nov': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'solve': 0.60; "you're": 0.61; 'back': 0.62; '2013': 0.98
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:to :content-type; bh=rupTpJ0b4bVDfSgfFV0JQt0ASwsvB5lTvViSwTdMLHg=; b=QLGqJFd7bgpGNMLLm8biQFMgY/y491s5CGnWP+/S670A4SOK1hvGVq+vlzItqpxbGC xkgVZNN1GXwWyK24bztbhO1DMZENvDhpHpf7FO/aZb8/OWDt+MIZoc8NnB8ooKQ3Alof XonxLd7i9jYdHI0a+WK2T7ZTvg5XQa6etMbmwjypEHF6M0FhqQt8ZLc27RT9iMy3G5PZ 9VhdoN5A/Nt5MnxAXQoC1+l5Rp6Qju4GU9pJfWPeQHcm7pLz7nVidDx//pCBrv9InjFO 1B18wd+SZn1+zPZWTF1XbJUaG9AJ51fNzRd2iXvARPwJi10rhP9y8bp184snIcN7k+RE mzAg==
MIME-Version 1.0
X-Received by 10.69.31.1 with SMTP id ki1mr7637603pbd.124.1385593894325; Wed, 27 Nov 2013 15:11:34 -0800 (PST)
In-Reply-To <27721690.YBritT5ChT@melforce>
References <5737051f-26d4-4771-b4a0-d41062f1a4ef@googlegroups.com> <52900c74$0$29993$c3e8da3$5496439d@news.astraweb.com> <27721690.YBritT5ChT@melforce>
Date Thu, 28 Nov 2013 10:11:34 +1100
Subject Re: python for everyday tasks
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.3328.1385593897.18130.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385593897 news.xs4all.nl 15917 [2001:888:2000:d::a6]:60751
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60647

Show key headers only | View raw


On Thu, Nov 28, 2013 at 5:05 AM, Pavel Volkov <negaipub@gmail.com> wrote:
> "Got a switch statement? The Python translation is a hash table, not a bunch
> of if-then statments. Got a bunch of if-then's that wouldn't be a switch
> statement in Java because strings are involved? It's still a hash table. "

I actually disagree. There is no Python translation for a switch
statement. What you have is two ways (if/elif and dict lookup) to
implement what in other languages is often implemented with a switch.
Often, switch is used when a dispatch table is the ideal solution; but
other times, neither if/elif nor a dispatch table will perfectly cover
what you're trying to do, and it's not right to "translate" the switch
into a dict lookup. The right thing to do is to go back to what's
actually trying to be solved, and solve that.

ChrisA

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


Thread

python for everyday tasks koch.mate@gmail.com - 2013-11-22 15:59 -0800
  Re: python for everyday tasks Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-23 02:01 +0000
    Re: python for everyday tasks wxjmfauth@gmail.com - 2013-11-25 02:12 -0800
      Re: python for everyday tasks Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-25 13:33 +0000
      Re: python for everyday tasks Michael Torrie <torriem@gmail.com> - 2013-11-25 08:11 -0700
        Re: python for everyday tasks wxjmfauth@gmail.com - 2013-11-25 08:17 -0800
      Re: python for everyday tasks Chris Angelico <rosuav@gmail.com> - 2013-11-26 02:38 +1100
      Re: python for everyday tasks Ben Finney <ben+python@benfinney.id.au> - 2013-11-26 10:35 +1100
      Re: python for everyday tasks Chris Angelico <rosuav@gmail.com> - 2013-11-26 11:09 +1100
    Re: python for everyday tasks Pavel Volkov <negaipub@gmail.com> - 2013-11-27 22:05 +0400
    Re: python for everyday tasks Michael Torrie <torriem@gmail.com> - 2013-11-27 11:15 -0700
    Re: python for everyday tasks Chris Angelico <rosuav@gmail.com> - 2013-11-28 10:11 +1100
  Re: python for everyday tasks Ned Batchelder <ned@nedbatchelder.com> - 2013-11-22 18:32 -0800
  Re: python for everyday tasks Dan Stromberg <drsalists@gmail.com> - 2013-11-22 22:28 -0800
  Re: python for everyday tasks Dan Stromberg <drsalists@gmail.com> - 2013-11-22 22:36 -0800
  Re: python for everyday tasks Chris Angelico <rosuav@gmail.com> - 2013-11-23 18:25 +1100
    Re: python for everyday tasks koch.mate@gmail.com - 2013-11-23 16:54 -0800

csiph-web