What does “while True” mean in Python?

while True means loop forever. The while statement takes an expression and executes the loop body while the expression evaluates to (boolean) “true”. True always evaluates to boolean “true” and thus executes the loop body indefinitely. It’s an idiom that you’ll just get used to eventually! Most languages you’re likely to encounter have equivalent idioms. … Read more

“x not in y” or “not x in y”

They always give the same result. In fact, not ‘ham’ in ‘spam and eggs’ appears to be special cased to perform a single “not in” operation, rather than an “in” operation and then negating the result: >>> import dis >>> def notin(): ‘ham’ not in ‘spam and eggs’ >>> dis.dis(notin) 2 0 LOAD_CONST 1 (‘ham’) … Read more

What is the meaning of the ${0##…} syntax with variable, braces and hash character in bash?

See the section on Substring removal in the Advanced Bash-Scripting Guideā€”: ${string#substring} Deletes shortest match of substring from front of $string. ${string##substring} Deletes longest match of substring from front of $string. The substring may include a wildcard *, matching everything. The expression ${0##/*} prints the value of $0 unless it starts with a forward slash, … Read more

href syntax : is it okay to have space in file name

The src attribute should contain a valid URL. Since space characters are not allowed in URLs, you have to encode them. You can write: <img src=”https://stackoverflow.com/questions/4172579/buttons/bu%20hover.png” /> But not: <img src=”https://stackoverflow.com/questions/4172579/buttons/bu+hover.png” /> Because, as DavidRR rightfully points out in his comment, encoding space characters as + is only valid in the query string portion of … Read more

What does the ‘=>’ syntax in C# mean?

It’s the lambda operator. From C# 3 to C# 5, this was only used for lambda expressions. These are basically a shorter form of the anonymous methods introduced in C# 2, but can also be converted into expression trees. As an example: Func<Person, string> nameProjection = p => p.Name; is equivalent to: Func<Person, string> nameProjection … Read more