for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
import logging
logger = logging.getLogger(__name__)
class IntMessageTranslator(object):
def translate(self, message):
If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example
class Foo: def some_method(self, x, y): return x + y;
could be written as
class Foo: @classmethod def some_method(cls, x, y): return x + y;
logger.info('Translating: {}'.format(message))
try:
content = int(message)
except ValueError:
content = None
return {'content': content}
If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example
could be written as