ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ctypes-users
ctypes-users
[ctypes-users] A recursive Structure
by Lenard Lindstrom other posts by this author
Nov 16 2006 2:02PM messages near this date
Re: [ctypes-users] PYFUNCTYPE, py_object and reference counting | Re: [ctypes-users] A recursive Structure
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.

Lenard Lindstrom
<len-l@[...].net> 



-------------------------------------------------------------------------
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved