[Pythonmac-SIG] cross-platform puzzle

Bob Ippolito bob at redivi.com
Tue Feb 22 02:03:26 CET 2005


On Feb 21, 2005, at 7:49 PM, Charles Hartman wrote:

> This may be the wrong list for this question. Send me away if so, but 
> I thought I'd try here first.
>
> I'm building Mac and Windows versions of an application with a 
> dictionary as one main data structure. A dialog box lets the user type 
> a string which is then used to change the value associated with one of 
> the keys, or to generate a new key-value pair. At least if the pair is 
> new, on Windows the test
> 		if word in self.Dict:
> 			newvalue = self.Dict[word]
> fails even though, in the debugger, the string I see for 'word' is 
> identical to one of the keys now visible in self.Dict. This is in 
> Windows only; the Mac version works fine.
>
> The dialog box is making the proper return on both platforms, and the 
> new key-value pair is being inserted into the dictionary. I haven't 
> yet checked what happens if the key was an existing one and only the 
> value is changed, and I suppose that might turn out to be the crucial 
> question. But either way, I'm very puzzled to find a cross-platform 
> disparity in this area. What am I missing?

I don't think you've provided enough detail to provide a useful guess.  
You don't even specify what "fails" means, let alone which toolkit 
you're using to collect the input from the user, etc.

Those two lines of code are going to do the same thing regardless of 
platform and should never raise an exception (if that's what "fail" 
means) -- assuming that Dict is a dict and word is a str or unicode 
(which is what you implied).

-bob



More information about the Pythonmac-SIG mailing list