Re: [Python-Dev] PEP 572: Usage of assignment expressions in C

2018年4月30日 01:13:31 -0700

2018年04月28日 17:45 GMT+02:00 Antoine Pitrou <[email protected]>:
> // Read up to n bytes from file descriptor
> if ((bytes_read = read(fd, buf, n)) == -1) {
> // Error occurred while reading, do something
> }
About C, there is a popular coding style (not used by our PEP 7) for comparison:
 if (-1 == n) ...
The advantage is to prevent typo mistakes because "-1 = n" is a syntax error.
Victor
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to