[Python-Dev] PEP 572: Usage of assignment expressions in C (original) (raw)
Victor Stinner vstinner at redhat.com
Mon Apr 30 04:02:53 EDT 2018
- Previous message (by thread): [Python-Dev] PEP 572: Usage of assignment expressions in C
- Next message (by thread): [Python-Dev] PEP 572: Usage of assignment expressions in C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2018-04-28 17:45 GMT+02:00 Antoine Pitrou <solipsis at pitrou.net>:
// Read up to n bytes from file descriptor if ((bytesread = 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
- Previous message (by thread): [Python-Dev] PEP 572: Usage of assignment expressions in C
- Next message (by thread): [Python-Dev] PEP 572: Usage of assignment expressions in C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]