Must function defs appear earlier than calls?

SeeBelow at SeeBelow.Nut SeeBelow at SeeBelow.Nut
Mon May 3 21:44:02 EDT 2004


John Roth wrote:
> 
> <SeeBelow at SeeBelow.Nut> wrote in message news:4096E9F8.38ABF26D at shaw.ca...
> > Must function defs appear earlier in a file than use of their name?
> 
> No. Function definitions must be executed before they
> are called, but they don't have to be before their
> calls.
> 
> The reason for this is that it's the execution of the function
> definition at run time that binds the function to the name in
> the dictionary, and that's where it has to be to be executed.
> 
> > If so, is there some way around this?  It's creating a puzzle for me.
> 
> Possibly you could say a bit more about what you're
> trying to do that's causing some perplexity?
> 
> John Roth
> >
> > Mitchell Timin

I'm using Tkinter, creating buttons and scales.  One of the buttons
should have a command option to execute a function that initializes some
class objects.  These objects take a scale object as one of their
initialization parameters, So I have to create the class objects after I
create the scales.

It seems that I must create the button that calls the initialization
function after that, or else the function assigned to the command option
is undefined.

But I want to create the button first, so that it appears near the top
of my frame.

I hope that's clear.  Now you see why I didn't describe that in my
original post!

And thanks for your help!

Mitchell Timin

-- 
"Many are stubborn in pursuit of the path they have chosen, few in
pursuit of the goal." - Friedrich Nietzsche

http://annevolve.sourceforge.net is what I'm into nowadays.
Humans may write to me at this address: zenguy at shaw dot ca



More information about the Python-list mailing list