在C++中,你可以通过谨慎使用"using"关键字来极大地提高代码的可读性,例如:
void foo()
{
std::vector< std::map <int, std::string> > crazyVector;
std::cout << crazyVector[0].begin()->first;
}
变成
void foo()
{
using namespace std; // limited in scope to foo
vector< map <int, string> > crazyVector;
cout << crazyVector[0].begin()->first;
}
Python中是否存在类似的东西,还是我必须完全限定每个内容?
我想添加一个免责声明,我知道使用“*”有其缺点,在范围上应适当加以限制。