Re: [Pyobjc-dev] NSRects and NSPoints as tuples...
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-01-08 22:00:00
|
On Wednesday, Jan 8, 2003, at 17:55 Europe/Amsterdam, Dinu Gherman wrote: > I've read somewhere and experienced now myself that NSRects and > NSPoints are mapped to 2-2 and 2-tuples of numbers respectively. > > While this is surely more convenient and more Pythonic in most cir- > cumstances I feel like it has the drawback that existing Cocoa > code calling attributes like size, width/height or x/y of NSRect > will need to be "ported" to the more Pythonic way in a more than > just syntactical fashion. > > In this case it means going from rather clear names to numeric > indices, which have a higher potential to confuse their users. > > Am I correctly assuming that this is working "as designed", then? > ;-) This is working as designed, but not because tuples are more pythonic than structs (I'm don't even think tuples are more pythonic). They are tuples because PyObjC doesn't know anything about NSRect and other struct-types, other than what it can extract from the runtime. The runtime doesn't know field names, but only the number and types of the fields. It would be possible to add an interface to specify custom mappings for structure types, but IMHO that is post-1.0 work. Ronald |