[Tutor] reason(s) for trailing comma in dict declarations

eryksun eryksun at gmail.com
Sat Aug 25 22:31:36 CEST 2012


On Sat, Aug 25, 2012 at 1:39 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> two adjacent strings without a comma get combined into a single string.
> Its a feature... mainly a remnant from the C foundations I suspect.

As a feature it can come in handy with long strings in expressions.

Just for reference about the "C foundations", here's a similar example in C.

    #include <stdio.h>

    int main() {

        int i, x_len;

        char *x[] = {
          "string1",
          "string2",
          "string3"  /* no comma */
          "string4"
        };

        x_len = sizeof(x) / sizeof(x[0]);

        for (i = 0; i < x_len; i++) {
            printf("%s\n", x[i]);
        }

        return 0;
    }

Output:

    string1
    string2
    string3string4


More information about the Tutor mailing list