c++ - Pass reference by reference in python -


Is it possible to pass reference from context in Python? To pass data in C ++, a pointer can be modeled to pass data by passing a pointer: The pointer passes from the value, and the function, which indicates, can change, but the value of the function indicator Can not change. However, in C ++ you can also pass the context of the pointer, in which case you can modify the pointer value and also this thing also.

Whatever is in my mind is an analog of the following: C + + Snippet, #include

The value of the Pointer P changes in the function that was passed; Output is' 3 'and' 5 '

If I' & amp; In the above function declaration, I get something that snippets the following:

  def funny (p): p = 5p = 3 print p fun (p) print p   

Which prints twice because the 'reference' in the fun body can not change the value of P. Any way to achieve behavior as above the C ++ bit?

(For completeness: I know that the model passing the dragon's data is not equal to passing a point from the value, because you do not need to explicitly clarify it within the function One reference is given from one value. However, I can not write the C ++ example by passing a reference by reference, because C ++ does not allow me to change references. Ignore R.).

No, you can not

alternative solutions To provide an example of a square, or unstable container, but these are both bad ideas in the long run, again to return the value again and return the global variable to its value.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -