[Pythonmac-SIG] How to find correct Carbon module(s)?

Bob Ippolito bob at redivi.com
Thu Feb 26 07:56:16 EST 2004


On Feb 26, 2004, at 6:50 AM, 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.

Eh, what about:

 >>> someobject = w.windowRef()
 >>> [k for k,v in sys.modules.items() if k.startswith('Carbon.') and 
type(someobject) in getattr(v, '__dict__', {}).values()]
['Carbon.Win']

-bob




More information about the Pythonmac-SIG mailing list