About 101,000 results
Open links in new tab
  1. python - How do I pass a variable by reference? - Stack Overflow

    Jun 12, 2009 · Python: Python is “pass-by-object-reference”, of which it is often said: “Object references are passed by value.” . Both the caller and the function refer to the same object, but the parameter in the function is a new variable which is …

  2. variables - Python functions call by reference - Stack Overflow

    Nov 9, 2012 · (note that the copied reference in the new box and the original both still point to the same object, here the reference IS the thing inside the box, not the object it is pointing to) 3. Pass by object-reference: the function creates a box, but it encloses the same thing the initial box was enclosing. So in Python:

  3. python - When is a variable passed by reference and when by …

    Everything in Python is passed and assigned by value, in the same way that everything is passed and assigned by value in Java. Every value in Python is a reference (pointer) to an object. Objects cannot be values. Assignment always copies the value (which is a pointer); two such pointers can thus point to the same object.

  4. Python : Call by Reference - Stack Overflow

    Nov 8, 2017 · Python's data model is quite different to C's, and the concept of call by reference doesn't really map well to Python. You may find this article helpful: Facts and myths about Python names and values, which was written by SO veteran Ned Batchelder. –

  5. Python: How do I pass a string by reference? - Stack Overflow

    May 23, 2017 · Python does pass a string by reference. Notice that two strings with the same content are considered identical: a = 'hello' b = 'hello' a is b # True Since when b is assigned by a value, and the value already exists in memory, it uses the same reference of the string.

  6. python - How to call a script from another script? - Stack Overflow

    As I found this, when I was searching for a solution in python 3. In python 3 you can just use the importfunctions (note that the py.files should not have a name as a library, it should have a unique name): File test1.py: print "I am a test" print "see! I do …

  7. Passing an integer by reference in Python - Stack Overflow

    Mar 1, 2013 · Python isn't C# (or Java) with a concept of boxing and unboxing. In the reference implementation, everything is just a PyObject. When you call a python function, python doesn't know (or care) about the type that is being passed. You can call the same function a bunch of times with different types in fact (consider the builtin str). There isn't ...

  8. Python call by ref call by value using ctypes - Stack Overflow

    Aug 10, 2013 · Python uses neither "call-by-reference" or "call-by-value" but "call-by-object". Assignment gives names to objects. test = c_int(56) t = 67 test is a name given to a ctypes.c_int object that internally has a value name assigned to an int object. t is a name give to an int object.

  9. python - How can I call a function within a class? - Stack Overflow

    In the OP, distToPoint() and isNear() are both instance methods and as such, both take a reference to an instance (usually named self) as its first argument. When an instance method called directly from the instance, the reference is passed implicitly, so. self.distToPoint(p) works.

  10. How do you call an instance of a class in Python?

    Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'object' object is not callable How can we call the instance as intended, and perhaps get something useful out of it? We have to implement Python special method, __call__!

Refresh