All Questions
Tagged with namedtuple struct
8
questions
7
votes
2
answers
1k
views
Why are NamedTuples and (immutable) structs separate?
Can someone explain why NamedTuples and immutable structs are separate instead of NamedTuples being an anonymous struct like there are anonymous functions function (x) x^2 end? They look like they ...
0
votes
2
answers
283
views
Inherited NamedTuple class with Factory
I have a class for decoding binary data using struct and storing in a NamedTuple as below:
class HEADER1(NamedTuple):
name: str
u2: int
tracetime: int
u4: int
u5: int
u6: int
...
2
votes
2
answers
526
views
Space-efficient pickling of Cython objects in Python?
I'm trying to find a space-efficient way to store a struct-like object in Python.
# file point.py
import collections
Point = collections.namedtuple('Point', ['x', 'y'])
Here's the cythonized ...
4
votes
6
answers
3k
views
Python mutable NamedTuple
I am looking for a struct like data structure I can create multiple instances from and have some type hinting without being immutable.
So I have something like this:
class ConnectionConfig(...
1
vote
2
answers
2k
views
Python NamedTuple to C++ Struct
I have searched the internet for hours at this point. Does anyone know how to parse a namedtuple returned from a python function into a struct or just into separate variables. The part I am having ...
0
votes
1
answer
76
views
Python Different the datetime in a Struct Array
import struct
from collections import namedtuple
StructDeviceInfo = namedtuple('DeviceInfo', ['DeviceID', 'Capturing','Receiving','Socket','DateTime'])
DeviceInfoList = []
def threaded_function():
...
2
votes
1
answer
6k
views
Python how to edit data in a namedtuple stored in a list?
import struct
from collections import namedtuple
StructPageNum = namedtuple('FDResult', ['DeviceID', 'PageNum','PicSize','PicData'])
PageNumList = []
Node = StructPageNum(DeviceID='NR09', PageNum=[],...
9
votes
3
answers
17k
views
Is there an elegant way to use struct and namedtuple instead of this?
I'm reading a binary file made up of records that in C would look like this:
typedef _rec_t
{
char text[20];
unsigned char index[3];
} rec_t;
Now I'm able to parse this into a tuple with 23 ...