1

In Python by pointer are passed: list, tuple and etc. Can i pass simple variables by pointer using ctypes module?

Someone
  • 95
  • 1
  • 13
  • Must you use `ctypes`? If not, see the last part of the answer in http://stackoverflow.com/questions/986006/how-do-i-pass-a-variable-by-reference. – kennytm Mar 17 '17 at 05:53
  • Why do you want to do that? – BrenBarn Mar 17 '17 at 05:55
  • I just started to deal with `ctypes` module and thought it was cool, if i could pass the variables by pointer in Python functions too. – Someone Mar 17 '17 at 06:02
  • What do you mean? All variables in Python have the same exact call semantics. There is not distinction between "simple" variables and others. They work the same. – juanpa.arrivillaga Mar 17 '17 at 06:28
  • I mean that i can change values of list via function like pointer in C++, but it is not work with simple variables. – Someone Mar 17 '17 at 07:11
  • 1
    @ИванСушков: That doesn't really have to do with pointers. It has to do with the fact that list objects make available certain operations (like `append`) that mutate the object. When you get an int, you also have a "pointer" to it, but you can't mutate it because the int object doesn't have any methods that would allow you to do so. – BrenBarn Mar 17 '17 at 17:39

0 Answers0