On 2018-05-10 17:10, Gustavo Carneiro wrote:
> IMHO, all these toy examples don't translate well to the real world because
> they tend to use very short variable names while in real world [good
> written code] tends to select longer more descriptive variable names.
> 
> Try replacing "c" with  a longer name, like input_command, then it becomes:
> 
>     while ((input_command = getchar()) != EOF) ...
> 
>     while (input_command = getchar(), input_command != EOF) ...
This thread really isn't about variable naming. I'll simply say that
I've always written the C idiom with `c` as the variable name, I've seen
literally hundreds of others do the same, and I've never seen anyone
spell it `input_command`.

I do the same in Python in a few contexts, usually where the variable's
meaning is very clear from its usage, or where the code in question
doesn't know or care what the variable is used for:

    for i in range(10):
    def get_const(self, x):
    for k in self.defaults.keys():

etc., and if we had `given` clauses, I'd probably do this there too. I
think one of the advantages of that syntax is that it makes it extremely
clear what's going on:

    if m given m = re.match(...):

I don't need to try to stuff an English description of m into its name,
because the `given` clause already describes it perfectly.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to