Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60647
| References | <5737051f-26d4-4771-b4a0-d41062f1a4ef@googlegroups.com> <52900c74$0$29993$c3e8da3$5496439d@news.astraweb.com> <27721690.YBritT5ChT@melforce> |
|---|---|
| Date | 2013-11-28 10:11 +1100 |
| Subject | Re: python for everyday tasks |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3328.1385593897.18130.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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