I have to declare some dict in Python. I write such a code:
class MegaClass(object):
_activation_grad_classes = \
{
activation.ForwardStrictRELU: activation.BackwardStrictRELU,
activation.ForwardLog: activation.BackwardLog,
activation.ForwardSinCos: activation.BackwardSinCos
}
And get a PEP-8 error: E122 continuation line missing indentation or outdented.
How can I fix it?
Put the opening curly brace on the assignment line:
_activation_grad_classes = {
activation.ForwardStrictRELU: activation.BackwardStrictRELU,
activation.ForwardLog: activation.BackwardLog,
activation.ForwardSinCos: activation.BackwardSinCos
}
There rarely is a need to use \ to escape a newline in Python; instead use {..}, [..] and (..) to group expressions across multiple lines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With