Fix Python – Most efficient way of making an if-elif-elif-else statement when the else is done the most?

I’ve got a in if-elif-elif-else statement in which 99% of the time, the else statement is executed:
if something == ‘this’:
doThis()
elif something == ‘that’:
doThat()
elif something == ‘there’:
doThere()
else:
doThisMostOfTheTime()

This construct is done a lot, but since it goes over every condition before it hits the else I have….

Fix Python – What is a None value?

I have been studying Python, and I read a chapter which describes the None value, but unfortunately this book isn’t very clear at some points. I thought that I would find the answer to my question, if I share it there.
I want to know what the None value is and what do you use it for?
And also, I don’t get this part of the book:

Assigning a value ….

Fix Python – Better to ‘try’ something and catch the exception or test if it’s possible first to avoid an exception?

Should I test if something is valid or just try to do it and catch the exception?

Is there any solid documentation saying that one way is preferred?
Is one way more pythonic?

For example, should I:
if len(my_list) >= 4:
x = my_list[3]
else:
x = ‘NO_ABC’

Or:
try:
x = my_list[3]
except IndexError:
x = ‘NO_ABC’

Some thoughts…
P….

Fix Python – Compare two columns using pandas

Using this as a starting point:
a = [[’10’, ‘1.2’, ‘4.2’], [’15’, ’70’, ‘0.03’], [‘8’, ‘5’, ‘0’]]
df = pd.DataFrame(a, columns=[‘one’, ‘two’, ‘three’])

which looks like
one two three
0 10 1.2 4.2
1 15 70 0.03
2 8 5 0

I want to use something like an if statement within pandas.
if df[‘one’] >= df[‘two’] and df[‘one’] <= df['t....

Fix Python – One line if-condition-assignment

I have the following code
num1 = 10
someBoolValue = True

I need to set the value of num1 to 20 if someBoolValue is True; and do nothing otherwise. So, here is my code for that
num1 = 20 if someBoolValue else num1

Is there someway I could avoid the …else num1 part to make it look cleaner? An equivalent to
if someBoolValue:
num1 = 20

I tri….