Should ‘using’ directives be inside or outside the namespace?

I have been running StyleCop over some C# code, and it keeps reporting that my using directives should be inside the namespace. Is there a technical reason for putting the using directives inside instead of outside the namespace? 12 There is actually a (subtle) difference between the two. Imagine you have the following code in … Read more

Why is “using namespace std;” considered bad practice?

I’ve been told by others that writing using namespace std; in code is wrong, and that I should use std::cout and std::cin directly instead. Why is using namespace std; considered a bad practice? Is it inefficient or does it risk declaring ambiguous variables (variables that share the same name as a function in std namespace)? … Read more

What does if __name__ == “__main__”: do?

What does this do? [python]if __name__ == "__main__": print("Hello world!") [/python]   40   Short It’s boilerplate code that protects users from accidentally invoking the script when they didn’t intend to. Here are some common problems when the guard is omitted from a script: If you import the guardless script in another script (e.g. import … Read more