[Tutor] Can't figure out syntax error

Alan G alan.gauld at freenet.co.uk
Fri Jun 10 10:16:36 CEST 2005

> frustration to figure out the problem, I just began explicitly
> type-casting as many variables as I could, and missed the fact that

Must be something about the mornings but I seem to be pickier then...

When you say type-casting that is a C term used to describe a horrible
operation that fools the C compiler into treating an arbitrary block
of bits in memory as some other type from that by which it was
It doesn't actually change the bits at all.

What Python provides is type conversion where it actually tries to
convert the data into a new value. Very different things.

This is best illustrated by a character.

char c = '5';   // ascii value 53
int n;

n = (int)c;  // type cast makes n hold 53
n = atoi(c)  // type convert makes n hold 5

Sorry for splitting hairs but clearing the terminology might help

Alan G.

More information about the Tutor mailing list