dry

How python function A executed when call function B?

How python function A executed when call function B? Question: The existing code is: class Base: def hello(self): print(‘hello’) class A(Base): def greet(self): self.hello() print(‘how are you?’) class B(Base): def greet(self): self.hello() print(‘how are you doing?’) How can I write code to implement that call self.hello() firstly when call self.greet(), but not add self.hello() in …

Total answers: 2

Best practice for reusing python code

Best practice for reusing python code Question: I have write a python library app(which contains several *.py files). And several of my python projects need to reuse the code in the library app. What’s the recommended best practice for reusing python code? Currently I have thought out three options: Copy and paste. This is far …

Total answers: 4

Django – use reverse url mapping in settings

Django – use reverse url mapping in settings Question: A few of the options in the django settings file are urls, for example LOGIN_URL and LOGIN_REDIRECT_URL. Is it possible to avoid hardcoding these urls, and instead use reverse url mapping? At the moment this is really the only place where I find myself writing the …

Total answers: 2