Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replicating struct in python

Tags:

python

struct

Is there anyway to support structures in python and does it not support the normal keyword struct?

for eg:

struct node
{
  unsigned dist[20];
  unsigned from[20];
}rt[10];

How can i covert this into a python struct?

like image 951
Abhishek Herle Avatar asked Nov 21 '25 17:11

Abhishek Herle


1 Answers

I think the Python's equivalent to C-structs is classes:

class Node:
    def __init__(self):
        self.dist_ = []
        self.from_ = []

rt = []
like image 185
aldeb Avatar answered Nov 23 '25 05:11

aldeb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!