[Pyobjc-dev] Re: Structs, tuples and instances
Brought to you by:
ronaldoussoren
From: Michael H. <mw...@py...> - 2003-10-31 11:28:15
|
Jack Jansen <Jac...@cw...> writes: > On 30 Oct 2003, at 10:36, Dinu Gherman wrote: > >> Hi, >> >> I'm trying to fake some kind of a solution which is more struct-like >> than plain Python tuples for things like NSPoint, NSSize, etc. This I can certainly sympathise with; I have some code like v1.setFrameOrigin_((0, v2.frame()[0][1] + v3.frame()[1][1])) which isn't especially clear. >> Here's a simple one: >> >> class NSPoint: > > I don't have a real reason for it, but my gut feeling is that the > Pythonic way to do this is the other way around: use a list as the > baseclass, and subclass that. Sounds reasonable. > Actually, what you really want (I think) > is something based on structmember, but I don't know whether that > allows read/write access, Yes. > and whether it's available from Python code. No. > Hmm, even if it isn't available from Python the objc core could make > it available. Using structmember for the various toolbox structures is > something that's also on my to-do list, but I haven't done anything > about it yet so I don't know how feasible this approach is. Well, I think the modern way is to define tp_members (think it's that one) which uses structmember under the hood rather than using structmember directly. I'm not sure what "available from Python" would really mean in this context. Cheers, mwh -- The only problem with Microsoft is they just have no taste. -- Steve Jobs, (From _Triumph of the Nerds_ PBS special) and quoted by Aahz on comp.lang.python |