[Tutor] Pointer handling

Alan Gauld alan.gauld@blueyonder.co.uk
Thu Jun 12 17:27:02 2003


Jimmy,

> I am having a problem with handling pointers.

Simply asking us to translate C uinto Python is probably not the
most effective approach. For one thing there is no direct
translation - Python does not have a separation betweeen pointers
and static variables and Python uses higher order data types
like lists instead of dumb arrays. Therefore if you give us a
clue what the code is trying to do we are better placed to help.

Also:

> ABC( XYZ *aa)

This would be better expressed to us as:

ABC(XYZ aa[])

to make it clear that you are expecting an array of XYZs not
just a reference to a single one.

>        bb = &aa[no];    // no is some integer value.

And its not clear here whether you want bb to refer to a
single element of aa or to refer to the list of aa from no
onwards. In C either use is possible, in Python they are
quite different things...

> def ABC(XYZ):
>       g = XYZ();
>

I'm not sure what this means. remember that indentation
means something in Python so this says you are dfining
a function ABC that takes a callable object (function or
class object) and then assigns the result to g(no semicolon
needed!) and then throws it all away and returns None(void)

I'm not sure what it has to do with the previous code.

Alan G.



>
>
> How the code here can behave like the code above.
>
>
> Waiting for the suggestions.
>
> Regards,
>
> Jim
>
> _________________________________________________________________
> Narain Karthikeyan. He's fast, really fast.
> http://server1.msn.co.in/sp03/tataracing/index.asp Want to meet him?
>
>
>