Skip to content

Instantly share code, notes, and snippets.

View nikiforidi's full-sized avatar
🚀
speak less, do more

Anatoli Nikiforidi nikiforidi

🚀
speak less, do more
View GitHub Profile
@nikiforidi
nikiforidi / settings.json
Last active April 13, 2021 15:06
Visual Studio Code configuration for Django projects using black, pylint and isort
{
"editor.formatOnSave": true,
"python.linting.lintOnSave": true,
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--load-plugins",
"pylint_django",
"--django-settings-module=core.settings",
"--max-line-length=120"
@nikiforidi
nikiforidi / climenu.py
Created August 7, 2020 15:58
Class method that defines a new class dynamically
def _set_api(self) -> None:
ApiClass = type(self._name.classname, (object, ), dict(actions=dict()))
num = 0
for option in self.options:
if option != 'exit':
num += 1
option = PyName(option)
code = compile('''def {}(self): print("{}")'''.format(
option.methodname,
self.api), "<string>", "exec")