Re: A question about reference in Python.

2008-12-08 Thread James Mills
In case the OP is interested here is a more complete implementation (others are welcome to comment): http://codepad.org/drIhqb7Z Enjoy :) cheers James -- -- -- Problems are solved by method -- http://mail.python.org/mailman/listinfo/python-list

Re: A question about reference in Python.

2008-12-08 Thread Joe Strout
On Dec 7, 2008, at 10:26 PM, Group wrote: Now, I want to write a Red-Black Tree, and a List structure. In C/C+ +, I can use pointers to refer to children notes (or next notes). But, in Python, how can I do it? Except the sequence, I know not any way. Any variable in Python is a

Re: A question about reference in Python.

2008-12-08 Thread Aaron Brady
On Dec 8, 9:18 am, Joe Strout [EMAIL PROTECTED] wrote: On Dec 7, 2008, at 10:26 PM, Group wrote: Now, I want to write a Red-Black Tree, and a List structure. In C/C+ +, I can use pointers to refer to  children  notes (or next notes). But, in   Python, how can I do it? Except the

Re: A question about reference in Python.

2008-12-08 Thread Steven D'Aprano
On Mon, 08 Dec 2008 08:18:27 -0700, Joe Strout wrote: On Dec 7, 2008, at 10:26 PM, Group wrote: Now, I want to write a Red-Black Tree, and a List structure. In C/C+ +, I can use pointers to refer to children notes (or next notes). But, in Python, how can I do it? Except the sequence, I

Re: A question about reference in Python.

2008-12-08 Thread Joe Strout
On Dec 8, 2008, at 7:43 PM, Steven D'Aprano wrote: On Mon, 08 Dec 2008 08:18:27 -0700, Joe Strout wrote: On Dec 7, 2008, at 10:26 PM, Group wrote: Now, I want to write a Red-Black Tree, and a List structure. In C/C + +, I can use pointers to refer to children notes (or next notes). But,

A question about reference in Python.

2008-12-07 Thread Group
Hello, I'm studying algorithom. For concentrating on the question itself, I intend to use Python to implement the algorithoms. Now, I want to write a Red-Black Tree, and a List structure. In C/C++, I can use pointers to refer to children notes (or next notes). But, in Python, how can I do

Re: A question about reference in Python.

2008-12-07 Thread Chris Rebert
On Sun, Dec 7, 2008 at 9:26 PM, Group [EMAIL PROTECTED] wrote: Hello, I'm studying algorithom. For concentrating on the question itself, I intend to use Python to implement the algorithoms. Now, I want to write a Red-Black Tree, and a List structure. In C/C++, I can use pointers to refer to

Re: A question about reference in Python.

2008-12-07 Thread Kermit Mei
Chris Rebert wrote: On Sun, Dec 7, 2008 at 9:26 PM, Group [EMAIL PROTECTED] wrote: Hello, I'm studying algorithom. For concentrating on the question itself, I intend to use Python to implement the algorithoms. Now, I want to write a Red-Black Tree, and a List structure. In C/C++, I can use

Re: A question about reference in Python.

2008-12-07 Thread James Mills
Hi, This is really really really pointless code and a really really pointless exercise, but nonetheless, here is a very very basic and minimal implementation of what you're expecting. This should almost *never* be done in Python! Python is a superior dynamic programming language, but it's NOT C!

Re: A question about reference in Python.

2008-12-07 Thread Chris Rebert
On Sun, Dec 7, 2008 at 10:09 PM, James Mills [EMAIL PROTECTED] wrote: Hi, This is really really really pointless code and a really really pointless exercise, but nonetheless, here is a very very basic and minimal implementation of what you're expecting. This should almost *never* be done in

Re: A question about reference in Python.

2008-12-07 Thread James Mills
On Mon, Dec 8, 2008 at 4:13 PM, Chris Rebert [EMAIL PROTECTED] wrote: The following three lines serve no purpose and can only lead to confusion: value = None prev = None next = None You are absolutely right :) Updated code: #!/home/jmills/bin/python -i class Node(object): def

Re: A question about reference in Python.

2008-12-07 Thread Chris Rebert
On Sun, Dec 7, 2008 at 10:17 PM, James Mills [EMAIL PROTECTED] wrote: On Mon, Dec 8, 2008 at 4:13 PM, Chris Rebert [EMAIL PROTECTED] wrote: The following three lines serve no purpose and can only lead to confusion: value = None prev = None next = None You are absolutely right :)

Re: A question about reference in Python.

2008-12-07 Thread James Mills
On Mon, Dec 8, 2008 at 4:25 PM, Chris Rebert [EMAIL PROTECTED] wrote: No apology necessary of course, i just didn't want the newbie OP to pick up any bad Python coding habits. Apologies that I might have phrased my criticism a bit harshly. No not at all :) I do use class variables in some