[Pythonmac-SIG] How to find correct Carbon module(s)?
Ronald Oussoren
oussoren at cistron.nl
Thu Feb 26 14:47:56 EST 2004
On 26-feb-04, at 12:50, Jack Jansen wrote:
>
> On 26-feb-04, at 7:38, Ronald Oussoren wrote:
>
>>
>> On 25-feb-04, at 22:45, Jack Jansen wrote:
>>
>>> If I'm not mistaken that's the answer to the first question (The
>>> '_Win' bits aren't optimal, but that can probably be fixed into
>>> Carbon.Win somehow), but the real problem is the second one: how do
>>> I find all the methods of all the objects, and put them in my
>>> namespace?
>>
>> I'm probably very dense, but why do you need to do that? The
>> _Win.Window bit in the repr of the method is the tp_name of
>> _Win.Window, if you change that the repr of methods also change (see
>> Objects/descrobject.c)
>
> I probably haven't made the point of the whole exercise clear enough:
> the problem is that you've found a routine (or object, or whatever)
> in the Apple documentation that you want to use. How to find out where
> in the forest of Carbon submodules is this function located?
>
> The idea is that for this purpose we create a single namespace that
> has everything. While you probably wouldn't want to use this namespace
> for day-to-day work (it's going to be a really big namespace) it would
> be handy to help you locate the place where MacPython puts the
> routine.
Ah, now I get it. You want to be able to use 'import Carbon.Carbon;
print Carbon.Carbon.TrackWindowProxyFromExistingDrag' to find
information about 'TrackWindowProxyFromExistingDrag' as defined in the
Carbon/Carbon.h header.
If T is an extension type (such as Carbon.Win.Window) the following
snippet will add the methods of the class to the global namespace:
MethodWrapperType = type(list.pop)
for name in dir(T):
o = getattr(T, name)
if isinstance(o, MethodWrapperType):
globals()[name] = o
BTW. I guess that if the big namespace exists people will use it for
day to day use, if only because of the way the Apple documentation is
structured.
Ronald
--
X|support bv http://www.xsupport.nl/
T: +31 610271479 F: +31 204416173
More information about the Pythonmac-SIG
mailing list