In C++ you can often drastically improve the readability of your code by careful usage of the "using" keyword, for example:
void foo()
{
std::vector< std::map <int, std::string> > crazyVector;
std::cout << crazyVector[0].begin()->first;
}
becomes
void foo()
{
using namespace std; // limited in scope to foo
vector< map <int, string> > crazyVector;
cout << crazyVector[0].begin()->first;
}
Does something similar exist for python, or do I have to fully qualify everything?
I'll add the disclaimer that I know that using has its pitfalls and it should be appropriately limited in scope.
Sure, python's dynamism makes this trivial. If you had a class buried deep in a namespace: foo.bar.baz.blah, you can do:
def foo:
f = foo.bar.baz.blah
f1 = f()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With