Re: [ctypes-users] A recursive Structure
by Thomas Heller other posts by this author
Nov 17 2006 11:35AM messages near this date
[ctypes-users] A recursive Structure
|
[ctypes-users] Accessing C part of PyObjects?
Lenard Lindstrom schrieb:
> The following ctypes structure example is decidedly un-C-like:
>
> Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]
> on win32
> Type "help", "copyright", "credits" or "license" for more
> information.
> >>> from ctypes import Structure, c_int, sizeof, __version__
> >>> __version__
> '1.0.1'
> >>> class S(Structure):
> ... pass
> ...
> >>> S._fields_ = [('i', c_int), ('s', S)]
> >>> sizeof(S)
> 4
> >>> o=S(7)
> >>> o.s.i=12
> >>> o.s.s.i=20
> >>> o.i
> 7
> >>> o.s.i
> 12
> >>> o.s.s.i
> 20
> >>> sizeof(o)
> 4
>
>
> This is certainly a novel way to create a singly-linked list. But I
> wonder if I want to know what it is doing to memory behind the
> scenes.
Probably not ;-). I have a fix for that, can you please submit a bug report
to the Python bug tracker?
Thanks,
Thomas
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
ctypes-users mailing list
ctypes-users@[...].net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Thread:
Lenard Lindstrom
Thomas Heller
|