Is Python type safe?
Joe Mason
joe at notcharles.ca
Wed Mar 17 00:36:14 EST 2004
In article <roy-0B9FC3.17134816032004 at reader1.panix.com>, Roy Smith wrote:
> I was once asked on an interview how I would tell, inside of a C
> program, if I was on a big endian or a small endian machine. I said I'd
> create a union of a long and a char[4], set the long equal to 1, and see
> which char it showed up in. The interviewer looked shocked, thought
> about it for a while, and finally said something like, "yeah, I guess
> that would work".
>
> To this day, I have no idea what other plan he had in mind.
unsigned short x = 1;
if (x == ntohs(x)) printf("Network byte order!\n");
else printf("Something else!\n");
Joe
More information about the Python-list
mailing list