Newbie NameError problem
Carsten Haese
carsten at uniqsys.com
Wed Dec 12 16:25:41 EST 2007
On Wed, 2007-12-12 at 12:48 -0800, MartinRinehart at gmail.com wrote:
> Thanks to all!
>
> I will put my class defs first (tho not without expressing my
> disappointment that this is required in a late 20th century language);
You don't have to physically *put* class definitions first in your code.
What matters is that they get *executed* first. They following will work
just fine:
#######################
def main():
x = SomeClass()
x.DoSomething()
class SomeClass:
...
main()
#######################
Expecting to use a class before it's defined is equivalent to expecting
this to work:
########################
print a
a = "Hello World"
########################
Even here in the early 21st century, we don't have clairvoyant computers
yet.
--
Carsten Haese
http://informixdb.sourceforge.net
More information about the Python-list
mailing list