In the project I'm working on, I split a lot of large files into smaller parts to make it easier to work with. One specific example is creating classes based views from functions based views in Django:
# app/views/LoginView.py class LoginView(View): ...
Above, I have to use LoginView twice when I want to call it, since importing LoginView imports the module, not the method from the module, although they have the same name. Ideally, I would like to call LoginView.LoginView every time.
In Javascript, I can just say export default function my_function() { ... } without naming it, and when it imported it by default, for example import my_function from './some_module.js';
Is there a way to do something like this in Python 3? I donβt want to do from app.views.LoginView import LoginView , because, especially in a large Django project and in a file like urls.py , it is not possible to import each on a separate line.
source share