[Tutor] Shortening the code

Asokan Pichai pasokan at talentsprint.com
Wed Nov 23 04:49:46 CET 2011


On Wed, Nov 23, 2011 at 2:47 AM, Mic <o0MB0o at hotmail.se> wrote:
>
[LOTS OF STUFF SNIPPED]
>>> self.chair1.configure(bg="green")
>>> os.remove ("Hamburg_Dortmund20_00")
>
>> And now you delete that file you created without having
>> done anything with it?
>
> The meaning is that when the button is pressed once,  it changes color and
> creates the file. That means you have
> booked the chair. If you click the button once more, the button removes the
> file, and changes color to green
> which indicates that you have un booked your chair. I hope you understand
> now why I delete the file :)

Often if you  [name things]/[write code] in terms of WHAT you want to do, rather
than HOW you want to do, you will find the going easier

For example, a function that is named *bookChair(chairId)*, inside which
you change color to green or whatever is worth considering.

HTH

Asokan Pichai


More information about the Tutor mailing list