Bizzare lst length problem

John Machin sjmachin at lexicon.net
Sun Oct 8 15:39:45 CEST 2006


Ben wrote:
> Ah - I found out why I had cast it to a string. I had not, at that
> point, worked out ho to pass the list by value rather than reference,
> and so was casting to a string as a stopgap measure that I then forgot
> about. Now the problem is fixed after this group told me how to pass a
> list by value (by slicing the entire list)
>

All argument passing is by reference. What you are calling "pass a list
by value" is actually two steps:

(1) make a copy of a list
(2) pass a reference to the copy

At the C implementation level, it's a (PyObject *) -- the address of
the object.

HTH,
John




More information about the Python-list mailing list