Y
Y
Yoshinon Eared2017-12-18 16:01:32
Python
Yoshinon Eared, 2017-12-18 16:01:32

Visual code formatting. Which option is acceptable?

1. So?

self._tg_api.send_photo(chat_id=self._chat_id, caption=_text,
                        photo=open(_content, 'rb'))

2. And like this?
self._tg_api.send_photo(chat_id=self._chat_id, 
                        caption=_text, photo=open(_content, 'rb'))

3. Or so?
self._tg_api.send_photo(chat_id=self._chat_id, 
                        caption=_text,
                        photo=open(_content, 'rb'))

4. Or maybe so?
self._tg_api.send_photo(
    chat_id=self._chat_id, 
    caption=_text,
    photo=open(_content, 'rb'))

What it's about: 80 character limit and readability.
Which option would you choose and why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-12-18
@Aquinary

All four options are valid. I usually make decisions based on the surrounding code.
For example, if I need to add something unimportant to a large script that is rarely read / edited by anyone, then I see no reason to take up three lines where two can do.
But if this is some key part of the logic and my colleagues will often refer to this place, then for greater readability I will write something that looks more like option 3, and I’ll also make the final bracket on a separate line, on the same level with the first bracket.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question