What is the preferred style for assigning values to variables when the variables are nested several levels deep, have fairly long names, and are being assigned fairly long values/expressions?
For example:
if this:
if that:
if here:
if there:
big_variable['big_key']['big_value'] = another_big_variable_that_pushes_line_over_79_characters
other_thing = something
The character-limit breaches are only in the single digits, but I want to clean up my code so that it follows PEP 8 as faithfully as possible. I've done the following, but I am still fairly new to python, and I'm not sure if it's the sort of thing that would make an experienced Python programmer cringe:
if this:
if that:
if here:
if there:
big_variable['big_key']['big_value'] = \
another_big_variable_that_pushes_line_over_79_characters
other_thing = something
I get the impression that the line continuation character is somewhat taboo; but I can't really think of a cleaner solution than the one I have if I'm working with these big dictionaries and I can't make a clean break in the middle of the variable name.
Flask
gives this proper context now. Your "cheap" fix is not cheap at all and if it works then it works. The overarching issue that we might be encountering here down the road is repetition -- not of variable names -- but of the fix itself. As the accepted answer pointed out, it might be a code smell, which is not always a technical mistake and most probably is a design flaw. That said, tell you what: test it out on your end. If you find yourself getting naming fatigue, then maybe it's time to look for a better hack. :) Good luck! – Subalternate