Anton Shishkov a écrit :
Hi, I can't figure out how can I change the variable type in function.
In C I could do that easily by changing pointer.
(snip)
Others already answered on this. Now, the real question is : why to you
want to do such a thing ?
Of one the most common use case for this
Hi, I can't figure out how can I change the variable type in function.
In C I could do that easily by changing pointer.
Please read about "mutable and immutable objects in Python". If you
understand the difference between them, you will get the idea. I'll
explain program anyway, showing you
On Tue, Apr 27, 2010 at 6:09 AM, Anton Shishkov
wrote:
> Hi, I can't figure out how can I change the variable type in function.
> In C I could do that easily by changing pointer.
>
> Code:
> def add(b):
>
> b = {}
> print type(b)
>
> a = []
> print type(a)
> add(a)
> print type(a)
>
> Output