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


Groups > comp.lang.python > #60629

Re: python for everyday tasks

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=0368e56e7=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'table.': 0.07; 'references.': 0.09; 'way:': 0.09; 'translate': 0.10; 'cc:addr :python-list': 0.11; 'python': 0.11; 'translation': 0.12; "wouldn't": 0.14; '"got': 0.16; 'article:': 0.16; 'involved?': 0.16; 'keys:': 0.16; 'subject:tasks': 0.16; 'subject:python': 0.16; 'java,': 0.16; 'wrote:': 0.18; 'written': 0.21; 'cc:addr:python.org': 0.22; 'case.': 0.24; 'refers': 0.24; 'java': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'statement': 0.30; 'url:mailman': 0.30; 'bunch': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'table,': 0.31; 'figure': 0.32; 'url:python': 0.33; '-----': 0.33; 'limitation': 0.33; 'table': 0.34; "can't": 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'thank': 0.38; 'url:2004': 0.39; 'though,': 0.39; 'url:12': 0.39; 'url:mail': 0.40; 'how': 0.40; 'details.': 0.61; 'first': 0.61; 'you.': 0.62; 'information': 0.63; 'received:194': 0.64; 'to:addr:gmail.com': 0.65; 'notice:': 0.67; 'person,': 0.68; 'saturday': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'either:': 0.91; 'medium.': 0.91; '2013': 0.98
X-IronPort-AV E=Sophos;i="4.93,784,1378850400"; d="scan'208";a="2174874"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Wed, 27 Nov 2013 19:16:06 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Pavel Volkov <negaipub@gmail.com>
In-Reply-To <27721690.YBritT5ChT@melforce>
Subject Re: python for everyday tasks
MIME-Version 1.0
X-Mailer Zimbra 7.2.4_GA_2900 (ZimbraWebClient - GC31 (Win)/7.2.4_GA_2900)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc 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 <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.3314.1385576168.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385576168 news.xs4all.nl 15969 [2001:888:2000:d::a6]:34039
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60629

Show key headers only | View raw


----- Original Message -----
> On Saturday 23 November 2013 02:01:26 Steven D'Aprano wrote:
> > * Python is not Java, and Java is not Python either:
> > 
> > http://dirtsimple.org/2004/12/python-is-not-java.html
> > http://dirtsimple.org/2004/12/java-is-not-python-either.html
> 
> Thanks for all those references.
> There's this statement in the first article:
> 
> "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 can't figure out how would you translate a switch statement into
> hash table
> in general case.
> --
> https://mail.python.org/mailman/listinfo/python-list
> 

It actually refers to python dictionaries, they use hash-able object as keys:

switch (foo):
  1: do_something()
  2: do_someotherthing()

can be written in python that way:

{
  1: do_something,
  2: do_someotherthing,
}[foo]()

There are some limitation though, without going into details.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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


Thread

Re: python for everyday tasks Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-11-27 19:16 +0100

csiph-web