Reputation: 49
I have a function with a return statement like:
return apple, banana, orange, pear, grape, kiwi
But it exceeds the maximum number of characters that flake8 lets me (in the example I've just put a dummy example), so how should I do it?
I've tried things like
return apple, banana, orange,\
pear, grape, kiwi
return apple, banana, orange,
pear, grape, kiwi
return apple, banana, orange,
pear, grape, kiwi
And nothing works. The last one was accepted by flake8 but it throws an execution error.
Thank you very much for your help
Upvotes: 0
Views: 470
Reputation: 69934
you didn't specify the error codes you're seeing -- flake8 doesn't implement any itself, but you're likely seeing codes from pycodestyle
(either E
/ W
)
pycodestyle accepts any of these:
def f():
return apple, banana, orange,\
pear, grape, kiwi
def f():
return (
apple, banana, orange,
pear, grape, kiwi,
)
def f():
return (
apple,
banana,
orange,
pear,
grape,
kiwi,
)
disclaimer: I'm the current flake8 maintainer and one of the pycodestyle maintainers
Upvotes: 1
Reputation: 388
You return a tuple, so you can do like this:
return (
apple,
banana,
orange,
pear,
grape,
kiwi
)
Upvotes: 2