What is a None value?

Martijn’s answer explains what None is in Python, and correctly states that the book is misleading. Since Python programmers as a rule would never say Assigning a value of None to a variable is one way to reset it to its original, empty state. it’s hard to explain what Briggs means in a way which … Read more

What is the relative performance difference of if/else versus switch statement in Java?

I totally agree with the opinion that premature optimization is something to avoid. But it’s true that the Java VM has special bytecodes which could be used for switch()’s. See WM Spec (lookupswitch and tableswitch) So there could be some performance gains, if the code is part of the performance CPU graph.

IF statement: how to leave cell blank if condition is false (“” does not work)

Unfortunately, there is no formula way to result in a truly blank cell, “” is the best formulas can offer. I dislike ISBLANK because it will not see cells that only have “” as blanks. Instead I prefer COUNTBLANK, which will count “” as blank, so basically =COUNTBLANK(C1)>0 means that C1 is blank or has … Read more

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

You should prefer try/except over if/else if that results in speed-ups (for example by preventing extra lookups) cleaner code (fewer lines/easier to read) Often, these go hand-in-hand. speed-ups In the case of trying to find an element in a long list by: try: x = my_list[index] except IndexError: x = ‘NO_ABC’ the try, except is … Read more

&& (AND) and || (OR) in IF statements

No, it will not be evaluated. And this is very useful. For example, if you need to test whether a String is not null or empty, you can write: if (str != null && !str.isEmpty()) { doSomethingWith(str.charAt(0)); } or, the other way around if (str == null || str.isEmpty()) { complainAboutUnusableString(); } else { doSomethingWith(str.charAt(0)); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)