|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Dictionary to Struct
At the moment, I am writing a Python module in C ( a wrapper around an API, to be more specific ). I have almost no experience with working in C, but I am managing to get by so far. However, I have run into a problem. Is there any way to easily convert a Python dictionary to a C struct?
Any help would be much appreciated! Regards, Peyton |
|
#2
|
|||
|
|||
|
You can create a C struct using the struct module (surprise surprise).
However a C struct is a fixed size, and a dictionary is a variable size, so there is no direct correspondence. If you mean you have a dict object with an entry for each member of the struct, then it should be quite easy. Read the docs for the struct library module for more information. Dave - The Developers' Coach |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Dictionary to Struct |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|