[Pythonmac-SIG] parameters to Scrap.GetScrap( ??, ??)

James B. Wilkinson jimmy@cs.cofc.edu
Sat, 23 Oct 1999 23:12:00 -0400


Joe Strout opined:

>At 8:10 PM -0700 10/22/99, James B. Wilkinson wrote:
>
>>    length, offset = Scrap.GetScrap(None, 'TEXT')
>>TypeError: Resource required
>
>I think it's your first resource that's the problem.  It should be a
>resource handle -- I don't think Python's GetScrap supports the behavior of
>peeking at the scrap without getting it.  So do
>
>	hdl = Res.Resource('')
>	length, offset = Scrap.GetScrap(hdl, 'TEXT')
>
>or something like that (typing from memory here).

Pretty good memory, I reckon. I just cut that and pasted it in. Bingo!
Well, after I had the presence of mind to import Res. Right proud of that,
I am.

Is there some place I should be able to find stuff like that for myself? I
didn't see anything like that in libmac.pdf, and I haven't found any other
docs for MacPython.


Another question, just in case the answer to the last one is "No":

Here's the end of the traceback I get if I start up the program right after
zeroing the scrap:

    TE.TEFromScrap()
Mac OS Error: (-102, 'No object of that type in scrap')

This looks like the relevant line in macerrors.py:
noTypeErr	=	-102	#No object of that type in scrap

My code at that point is

	try:
		TE.TEFromScrap()
	except macerrors.noTypeErr:
		print "Caught it!"	#For debugging
		pass

If I change the except line to just "except:", then the program prints
"Caught it!" and keeps on running ok.

So I've gotten myself mystified again. I'd much prefer to have the specific
error named in the except line so I'll hear about it if some other error
comes along sometime. Unfortunately, I can't figure out what to call this
error that I want to catch. noTypeErr seems to be the obvious thing, and it
don't work.

Guidance gratefully received.


-------------------------------------------------------------
Jimmy Wilkinson            | Perfesser of Computer Science
jimmy@cs.CofC.edu          | The College of Charleston
(843) 953-8160             | Charleston      SC        29424

If there is one word to describe me,
that word would have to be "profectionist".