Fuzzyman wrote:
> I'm not familiar with the C basic datatypes - I assume it has an array
> or list like object.
>
> Would it contain a sequence of poitners to the members ? In which case
> they would only be equal if the pointers are the same.
>
> In this case :
>
> a = ['some string']
> b = ['somestring']
> a == b
> False (probably)
>
> Incorrectly using Python syntax for a C example of course :-)
>
That depends, the C syntax is like this :

char *a="hello";
char *b="hello";

assert(a==b);

// true, the compiler knows the two hello are the same and assign the
same address(sort of id() in python) to a and b

But the following is not

char *a="hello";
char *b="_hello";
char *c=b+1;

assert(a==c); //false, even the content they point to are the same

However, string in the above are not basic types of C and if you want
to compare the value(like comparing integer), you need to use function
like strcmp() which again compare byte by byte in the above example and
give true.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to