[Python-ideas] globals should accept parenteses for extending beyond 1 line
João Matos
jcrmatos at gmail.com
Mon Jan 23 16:18:54 EST 2017
Hello,
The subject of this topic is a suggestion about the language and not the
programming paradigm/style.
Why should I repeat global if I can use the line separation character \
(like I mentioned on my 1st email) or parentheses as I suggested?
"global existing_graph, expected_duration # "in_sec" is unnecessary"
No it is not unnecessary unless sec is the only unit you use (in this
case we have several units of duration and thus it is necessary).
Best regards,
JM
On 23-01-2017 20:24, Chris Angelico wrote:
> On Tue, Jan 24, 2017 at 6:37 AM, João Matos <jcrmatos at gmail.com> wrote:
>> One does not need to have 10 global vars. It may have to do with var name
>> length and the 79 max line length.
>>
>> This is an example from my one of my programs:
>> global existing_graph, expected_duration_in_sec, file_size, \
>> file_mtime, no_change_counter
>>
> I think you're already running into serious design concerns here. Why
> are file_size and file_mtime global? Perhaps a better design would
> involve a class, where this function would become a method, and those
> globals become "self.file_size" and "self.file_mtime". Then you can
> have a single global instance of that class for now, but if ever you
> need two of them, it's trivially easy. You encapsulate all of this
> global state into a coherent package.
>
> But if you MUST use globals, I would split the lines according to purpose:
>
> global existing_graph, expected_duration # "in_sec" is unnecessary
> global file_size, file_mtime
> global no_change_counter # also probably needs a new name
>
> That way, you're unlikely to run into the 80-char limit.
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
More information about the Python-ideas
mailing list