How to Work with 'Pointers' in Python

Pointers in Python is a memory location. It has three identities - Name, Value, and Location (Address). Python supports Pointers for writing C logic. For this purpose, you need the ctypes library.

What is Pointer?

1. It has value
2. It has an address
3. It has Name

Python does not support Pointers in Python. If you want to write C logic, or to deal with C applications you need ctypes.
Python Pointers

Python Pointers.

If the Python does not has a Pointer data type, why it supports it. The main reason is to deal with C- Interface.  The best example is sending an address instead of the actual value.

How to Import 'ctypes' in Python (Windows/Linux)?

To work with C, in Python you need to import a 'ctypes' library. Read here how to import 'ctypes' for windows and Linux.

How to Use Pointers in Python?

  • To pass a reference(address) to the C interface.
  • To write C functions in Python.
  • Once ctypes library present, then you can write C logic in Python.



Popular Posts

Hyperledger Fabric: 20 Real Interview Questions

7 AWS Interview Questions asked in Infosys, TCS

How to Fix Python Syntax Errors Quickly

Python 'getsizeof' Command the Real Purpose

Blue Prism complete tutorials download now

Python Dictionary Vs List With Examples

How to Use the ps Command in Linux

Vi Editor to Quit use Esc and Colon

5 HBase Vs. RDBMS Top Functional Differences

The Growth of Machine Learning till TensorFlow