tkinter questions: behavior of StringVar, etc

Rhodri James rhodri at wildebst.demon.co.uk
Sun Mar 29 21:05:20 EDT 2009


On Mon, 30 Mar 2009 00:45:41 +0100, Alan G Isaac <alan.isaac at gmail.com>  
wrote:
> On 3/29/2009 6:49 PM Scott David Daniels apparently wrote:
>> What happens to your TV when you change the channel before turning it  
>> on?
>
> I think we can agree this is a safe action, but the result
> depends  on the kind of TV (and on what "turning it on" means).
> So I think your analogy makes my point: allowing
> the state of the variable to be registered at use rather than
> creation is feasible, although it would perhaps not be best.
> (E.g., it would not be simplest.)

s/simplest/safest/.  The chances of something going wrong if you
have a staggered setup like that are quite high.  The chances of
someone trying to use a ???Var before any of the rest of the
system is set up (and, if they're lucky, seg-faulting) shouldn't
be overlooked either.

Amusingly, I'm just old enough to remember when the answer to
Scott's question was "you probably get static, because the odds
of turning the dial to exactly the right spot are small."

>> Printing a StrVar is not the same as printing the contents of a  
>> StrVar.  Having "magic" conversions happen for you when they can be  
>> useful simply allows you to make mistakes about what things are what.
>
> This sounds like an argument against duck typing, and maybe
> even an argument for eliminating most of the special method
> names, although I'm sure you did not mean it to be this.  ;-)

When you're talking implementation details (which is most of
what we're doing), duck typing does allow you to make mistakes
about what's actually happening.  That's the whole point of
it.

-- 
Rhodri James *-* Wildebeeste Herder to the Masses



More information about the Python-list mailing list