Tkinter callback arguments

Alf P. Steinbach alfps at start.no
Wed Nov 4 21:55:53 EST 2009


* Alf P. Steinbach:
> * Steven D'Aprano:
>> On Wed, 04 Nov 2009 08:50:42 +0100, Alf P. Steinbach wrote:
>>
>>> * Gabriel Genellina:
>>>> I don't understand either. R1 and R2 have *different* semantics.
>>> Assume that they have the very exact same semantics  
>>
>>
>> Why would we assume that when you have explicitly told us that they 
>> don't?
>>
>> You stated categorically that they behave differently when you assign 
>> to the attribute/property "top".
> 
> Uh, severe reading difficulties ... referring to self in plural ... Hm. :-)
> 
> But anyway, in the example description I wrote
> 
>   "With R1 direct changes of left and top keeps the rectangle's size"
> 
> and this is in the context of a discussion of modifying data attributes 
> directly versus using properties.

Perhaps this makes it more clear: in R1, which has a width/height based 
rectangle representation, assigning directly to the top data attribute 
/effectively/ moves the rectangle vertically without changing its height, since 
the height attribute is unchanged.

But that does not reflect any intended semantics, it's not a requirement; it's 
an implementation artifact, a behavior that just results from direct 
modification and the choice of a particular rectangle representation.

Real world Python example of that kind of artifact: as discussed in some other 
thread here, doing open( ..., 'r+' ) followed by write followed directly by read 
will on some implementations/systems produce garbage. Presumably because those 
implementations use C "FILE*" to implement the functionality, and implements it 
by a fairly direct mapping of calls down to the C level, where this sequence is 
in general Undefined Behavior. You might regard it as semantics, and it's quite 
real and presumably in a sense well-defined for the particular implementation on 
the particular system, but it's not part of any intended semantics, and any who 
relies on that behavior is doing it at other's risk.

For the R1 class the indended semantics, the specification that the programmer 
was handed down or produced or had in mind, might include just rectangle 
construction, checking intersection with other rectangle, and obtaining any of 
three pairs of values: left upper corner, right lower corner and width+height.

For example. :-)


Cheers & hth.,

- Alf



More information about the Python-list mailing list