Skip to content

Instantly share code, notes, and snippets.

@jaredlockhart
Created May 5, 2017 19:25
Show Gist options
  • Select an option

  • Save jaredlockhart/a396efe6dc651abbfa89c4a2bd9aaa89 to your computer and use it in GitHub Desktop.

Select an option

Save jaredlockhart/a396efe6dc651abbfa89c4a2bd9aaa89 to your computer and use it in GitHub Desktop.
# How do we indent long lines
# Example one
# Too long
fields = ('slug', 'name', 'description', 'start_date', 'end_date')
# If you're just over 80 characters, you can do this, it's the simplest
# form of satisfying the 80 character max
fields = (
'slug', 'name', 'description', 'start_date', 'end_date')
# If you're way over 80 characters, you have to move each element to its own line like this
fields = (
'slug',
'name',
'description',
'start_date',
'end_date', # always include a trailing comma, they're legal and make refactoring easier
)
# I do not like tooth brush indentation
fields = ('slug', 'name', 'description',
'start_date', 'end_date')
# because it makes refactoring later harder, for instance if you change the name `fields`
# now you have to change the indentation on the following line,
# or if you want to add a new field name or change the order of them
# then you have to move every line around
@jaredlockhart
Copy link
Author

jaredlockhart commented May 5, 2017

I've seen people do:

birds = Bird.objects.all().filter(cute=True).order_by('this',
                                                      'that',
                                                      'the other',
                                                      'like....seriously?')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment