Let me explain a little better with some code. class Opcode (Enum):     WEEK=    1     EMAIL=   2     NAME=    3     DOB=     4  I then have a parameters class which processes data received by the server, and stores it in the appropriate variable : class parameters:     week = None     email = None     name = None     dob = None          def __init__(self, conn):         #some initialization stuff, irrelevant              def process_input(self, opcode, data):         if opcode == Opcode.WEEK.value:             self.week = data                      elif opcode == Opcode.EMAIL.value:             self.email= data                   elif opcode == Opcode.NAME.value:             self.name= data          elif opcode == Opcode.DOB.value:             self.dob= data          .          .          .           else :             print(&quot;unknown opcode provided. disconnecting ... &quot;)             #disconnect from client ...  This doesn't seem too bad with only 4 opcodes, but in reality my  program has 12 opcodes and so this long if...elif...elif...else branch seems like a bad way of processing inputs. I'm use to working with C++, in which case I'd have used a switch-case, but they don't appear to be a thing in python, so perhaps there is a better solution I just don't know about. Any advice?
I want to write a function in Python that returns different fixed values based on the value of an input index.    In other languages I would use a switch or case statement, but Python does not appear to have a switch statement.  What are the recommended Python solutions in this scenario?
C# and USB HID Devices Create ArrayList from array This is by far the weirdest problem I've come across,  My mac can perfectly access internet through safari web browser, but when I tried to do   ping www.google.com   through the terminal, it's requests is being timed out.  None of the other apps are able to reach internet either. Dropbox, Skype, Spotify all showing offline, except the browser itself  I'm guessing something bad with the DNS, but spend 2 hours trying to fix this with no luck How to pause with specific time between two command in script? I want to do such as following:  #!/bin/bash command1 pause 30 seconds command2 exit   This is only example script with pause of 30 seconds between run of 2 command.  How to do this? Is there a "null coalescing" operator in JavaScript? Why isn't the gamma function defined so that $\Gamma(n) = n! $? I have this MySQL query:  SELECT DAYOFYEAR(`date`)  AS d, COUNT(*)  FROM  `orders`  WHERE  `hasPaid` &gt; 0 GROUP  BY d ORDER  BY d   Which returns something like this:  d  | COUNT(*) | 20 |  5       | 21 |  7       | 22 | 12       | 23 |  4       |   What I'd really like is another column on the end to show the running total:  d  | COUNT(*) | ??? | 20 |  5       |   5 | 21 |  7       |  12 | 22 | 12       |  24 | 23 |  4       |  28 |   Is this possible? Do you say IN one of the computers or ON one of the computers? Which is right? I need to define a new command to create a squiggle arrow with some text on it. Something similar to what \xrightarrow command produces but with wiggly arrows as in \rightsquigarrow. The length of the arrow should automatically be adjusted to fit the text above it and I do not know how to handle this part in TikZ. Any ideas would be much appreciated. Can binary data be ordinal? Binary data is often mentioned as a nominal sub-category, especially in such examples as female/male, smoker/non-smoker, etc. However, binary data with such values as pass/fail, correct/incorrect, absent/present, etc, seems to give some weight to its values. It's not like in the example of the gender, where both values are equal and differ primarily by the nominal and other context-related traits. Instead, this type of binary data clearly indicates that one value means something and the other means nothing.   In case of such distinction, can binary be considered ordinal? If yes, what are statistical tests that are usually used for such data? Also, are there any interesting books or papers on this case? Learning special relativity and working with Minkowski diagrams for a while now i am still trying to get my head around some oddity.   From my understanding time can often be seen as the dependent variable in those diagrams, so why put it to the vertical axis? What confuses me even more is the apparent convention to denote a point in space time $(t,x)$ even though $x$ is on the horizontal and $t$ is on the vertical axis, so the usual notation would be to refer to that vector as $(x, t)$.  Are there mostly historical reasons or why is it beneficial to use this notation and to violate usual conventions? Extracting matrix rows when one of its elements is part of a list (without a loop) List of blogs to learn more about Ubuntu Add blogs and websites that are useful in the quest to know/learn more about Ubuntu.  One blog per answer, please - you can vote answers up/down as you feel appropriate. If you feel the blog is biased towards or is good for particular tasks, please mention them. bibtex and genitive / possessive 's: the proper way to obtain "Kuran's (1989) model" Is there an automatic way to attach a genitive apostrophe or " ' s " to an author's name?  Currently I use:  \citeauthor{kuran1989}'s \citeyear{kuran1989}   But since this comes up regularily I'd like to know whether there's a general solution. Make back/forward work on paginated lists Proving a limit of a trigonometric function: $\lim_{x \to 2/\pi}\lfloor \sin \frac{1}{x} \rfloor=0$ $$\lim_{x \to \frac{2}{\pi}}\lfloor \sin \frac{1}{x} \rfloor=0$$    I need to prove the limit of this using the $\epsilon - \delta $ way but I don't know how to find $\delta$ when I'm given a trigonometric function I know only how to do it with polynomial functions Format a number with optional decimal places in Excel I have numbers in cells in Excel. I want the numbers formatted so that if they have decimal places they show to a maximum of two, and if they have no decimal places it doesn't show any.  For example.    15 should be formatted as 15, NOT 15.00 14.3453453 should be formatted as 14.35 12.1 should be formatted as 12.1  0 should be formatted as 0   The closest custom format code I've come up with is 0.##. Unfortunately this formats 15.00 as 15. (note the extra decimal point).  To further complicate the issue, the spreadsheet is a result of an export from SQL Server Reporting Services. So no macros are possible. Oh well, it looks like 0.## is my best bet, and they can just live with the extra period. My hypothesis is that $\mathbb{R \times R}$,  the set of all pairs $(r_1, r_2)$, of real numbers is uncountable. I understand that the set of all pairs of natural numbers is countable. But could someone explain why the set of all pairs of real numbers uncountable? I am having trouble proving it using diagolization Which arena do free and crown chests use when determining the cards you will get? I have recently noticed that in chat when I type enough and the profile picture expands with my message, the hat stays the same size and it stays in the same place (I have the  app):