some questions....
Brian Quinlan
brian at sweetapp.com
Tue Nov 26 02:46:59 EST 2002
Tim Roberts wrote:
> >if __name__ == '__main__':
> > a = 3;
> > b = 4;
> > c = simple(a)
>
> At this point, the variable "C" does not exist. That's why you get an
> error. What surprises ME is that it was able to find "c". What that
> tells me is that the interpreter creates the object, assigns it to
"c",
> and THEN calls __init__. __init__, then, is able to find the global
> variable "c".
Tim, you have gone completely crazy and I fear that you might spread
your insanity to others :-)
Look at the constructor implementation again. Those print statements are
not executed unless the constructor is called with 4 as an argument.
That doesn't happen until after c has been assigned.
Cheers,
Brian
More information about the Python-list
mailing list